Skip to content

Commit

Permalink
Use a simpler regex to avoid potential Stack Overflow
Browse files Browse the repository at this point in the history
Fixes #2165
  • Loading branch information
jhy committed Jul 5, 2024
1 parent 65589f1 commit 97e6211
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
e.g.: `h1:has(+h2)`). [2137](https://github.com/jhy/jsoup/issues/2137)
* The `:empty` selector incorrectly matched elements that started with a blank text node and were followed by
non-empty nodes, due to an incorrect short-circuit. [2130](https://github.com/jhy/jsoup/issues/2130)
* Fuzz: a Stack Overflow exception could occur when resolving a crafted `<base href>` URL, in the normalizing regex.
[2165](https://github.com/jhy/jsoup/issues/2165)

---

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jsoup/internal/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static boolean isAscii(String string) {
return true;
}

private static final Pattern extraDotSegmentsPattern = Pattern.compile("^/((\\.{1,2}/)+)");
private static final Pattern extraDotSegmentsPattern = Pattern.compile("^/(?>(?>\\.\\.?/)+)");
/**
* Create a new absolute URL, from a provided existing absolute URL and a relative URL component.
* @param base the existing absolute base URL
Expand Down
Binary file added src/test/resources/fuzztests/67469.html.gz
Binary file not shown.

0 comments on commit 97e6211

Please sign in to comment.