Skip to content

Commit

Permalink
Fixed an OOB in TreeBuilder when getting the body Element
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy committed Jun 19, 2022
1 parent e714ef1 commit 8733445
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/jsoup/parser/HtmlTreeBuilderState.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,9 @@ private boolean inBodyStartTag(Token t, HtmlTreeBuilder tb) {
return false; // ignore
} else {
tb.framesetOk(false);
Element body = stack.get(1);
if (startTag.hasAttributes()) {
// will be on stack if this is a nested body. won't be if closed (which is a variance from spec, which leaves it on)
Element body;
if (startTag.hasAttributes() && (body = tb.getFromStack("body")) != null) { // we only ever put one body on stack
for (Attribute attribute : startTag.attributes) {
if (!body.hasAttr(attribute.getKey()))
body.attributes().put(attribute);
Expand Down
Binary file added src/test/resources/fuzztests/48116.html.gz
Binary file not shown.

0 comments on commit 8733445

Please sign in to comment.