Skip to content

Commit db7a072

Browse files
committed
Re2j complexity exception check
1 parent b3bf673 commit db7a072

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main/java/org/jsoup/helper/Re2jRegex.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public static Regex compile(String regex) {
1818
return new Re2jRegex(com.google.re2j.Pattern.compile(regex));
1919
} catch (RuntimeException e) {
2020
throw new ValidationException("Pattern syntax error: " + e.getMessage());
21+
} catch (OutOfMemoryError | StackOverflowError e) { // defensive check on regex to normalize exception
22+
throw new ValidationException("Pattern complexity error: " + e.getMessage());
2123
}
2224
}
2325

0 commit comments

Comments
 (0)