Skip to content

Commit

Permalink
Per spec, only foster incoming nodes if current node is a table foste…
Browse files Browse the repository at this point in the history
…r target
  • Loading branch information
jhy committed Sep 27, 2021
1 parent 41932fe commit e4ae6fa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jsoup/parser/HtmlTreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.jsoup.nodes.FormElement;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;
import org.jsoup.select.Elements;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
Expand All @@ -20,6 +19,7 @@
import java.util.List;

import static org.jsoup.internal.StringUtil.inSorted;
import static org.jsoup.parser.HtmlTreeBuilderState.Constants.InTableFoster;

/**
* HTML Tree Builder; creates a DOM from Tokens.
Expand Down Expand Up @@ -315,7 +315,7 @@ private void insertNode(Node node) {
// if the stack hasn't been set up yet, elements (doctype, comments) go into the doc
if (stack.isEmpty())
doc.appendChild(node);
else if (isFosterInserts())
else if (isFosterInserts() && StringUtil.inSorted(currentElement().normalName(), InTableFoster))
insertInFosterParent(node);
else
currentElement().appendChild(node);
Expand Down

0 comments on commit e4ae6fa

Please sign in to comment.