Skip to content

Commit de2bfde

Browse files
committed
Confirm current el is frameset before attempting to pop
Fixes #2397
1 parent dedf6ab commit de2bfde

File tree

5 files changed

+10
-1
lines changed

5 files changed

+10
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* When using the JDK HttpClient, any system default proxy (`ProxySelector.getDefault()`) was ignored. Now, the system proxy is used if a per-request proxy is not set. [#2388](https://github.com/jhy/jsoup/issues/2388), [#2390](https://github.com/jhy/jsoup/pull/2390)
1212
* A ValidationException could be thrown in the adoption agency algorithm with particularly broken input. Now logged as a parse error. [#2393](https://github.com/jhy/jsoup/issues/2393)
1313
* Null characters in the HTML body were not consistently removed; and in foreign content were not correctly replaced. [#2395](https://github.com/jhy/jsoup/issues/2395)
14+
* An IndexOutOfBoundsException could be thrown when parsing a body fragment with crafted input. Now logged as a parse error. [#2397](https://github.com/jhy/jsoup/issues/2397)
1415

1516

1617
## 1.21.2 (2025-Aug-25)

src/main/java/org/jsoup/parser/HtmlTreeBuilderState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ else if (name.equals("col")) {
16871687
return false;
16881688
}
16891689
} else if (t.isEndTag() && t.asEndTag().normalName().equals("frameset")) {
1690-
if (tb.currentElementIs("html")) { // frag
1690+
if (!tb.currentElementIs("frameset")) { // spec checks if el is html; deviate to confirm we are about to pop the frameset el
16911691
tb.error(this);
16921692
return false;
16931693
} else {

src/test/java/org/jsoup/integration/FuzzFixesTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ void testHtmlParse(File file) throws IOException {
5656
assertNotNull(doc);
5757
}
5858

59+
@ParameterizedTest
60+
@MethodSource("testFiles")
61+
void testHtmlFragmentParse(File file) throws IOException {
62+
String html = ParseTest.getFileAsString(file);
63+
Document doc = Jsoup.parseBodyFragment(html);
64+
assertNotNull(doc);
65+
}
66+
5967
@ParameterizedTest
6068
@MethodSource("testFiles")
6169
void testXmlParse(File file) throws IOException {
105 Bytes
Binary file not shown.
-7.71 KB
Binary file not shown.

0 commit comments

Comments
 (0)