From 03ac9a5afdb9fcf8cb7815fdae9da60825a266bd Mon Sep 17 00:00:00 2001 From: "Thomas E. Enebo" Date: Wed, 24 Jul 2024 14:39:35 -0400 Subject: [PATCH] Make joni.regex_max_length opt-in as it will break existing users with big intentional regexps --- src/org/joni/Config.java | 2 +- src/org/joni/Regex.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/joni/Config.java b/src/org/joni/Config.java index 5257fbf..b5f4a92 100644 --- a/src/org/joni/Config.java +++ b/src/org/joni/Config.java @@ -22,7 +22,7 @@ import java.io.PrintStream; public interface Config extends org.jcodings.Config { - final int REGEX_MAX_LENGTH = ConfigSupport.getInt("joni.regex_max_length", 15000); + final int REGEX_MAX_LENGTH = ConfigSupport.getInt("joni.regex_max_length", -1); final int CHAR_TABLE_SIZE = ConfigSupport.getInt("joni.char_table_size", 256); final boolean USE_NO_INVALID_QUANTIFIER = ConfigSupport.getBoolean("joni.use_no_invalid_quantifier", true); final int SCANENV_MEMNODES_SIZE = ConfigSupport.getInt("joni.scanenv_memnodes_size", 8); diff --git a/src/org/joni/Regex.java b/src/org/joni/Regex.java index 10099ed..031fc49 100644 --- a/src/org/joni/Regex.java +++ b/src/org/joni/Regex.java @@ -151,7 +151,7 @@ public Regex(byte[]bytes, int p, int end, int option, Encoding enc, Syntax synta // onig_alloc_init public Regex(byte[]bytes, int p, int end, int option, int caseFoldFlag, Encoding enc, Syntax syntax, WarnCallback warnings) { - if ((end - p) > Config.REGEX_MAX_LENGTH) { + if (Config.REGEX_MAX_LENGTH > 0 && (end - p) > Config.REGEX_MAX_LENGTH) { throw new ValueException(ErrorMessages.REGEX_TOO_LONG); }