Skip to content

Commit

Permalink
Make joni.regex_max_length opt-in as it will break existing users wit…
Browse files Browse the repository at this point in the history
…h big intentional regexps
  • Loading branch information
enebo committed Jul 24, 2024
1 parent 486d1dd commit 03ac9a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/org/joni/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/org/joni/Regex.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 03ac9a5

Please sign in to comment.