|
21 | 21 | import static org.jsoup.internal.StringUtil.inSorted;
|
22 | 22 | import static org.jsoup.parser.HtmlTreeBuilderState.Constants.InTableFoster;
|
23 | 23 | import static org.jsoup.parser.HtmlTreeBuilderState.ForeignContent;
|
24 |
| -import static org.jsoup.parser.Parser.NamespaceHtml; |
| 24 | +import static org.jsoup.parser.Parser.*; |
25 | 25 |
|
26 | 26 | /**
|
27 | 27 | * HTML Tree Builder; creates a DOM from Tokens.
|
28 | 28 | */
|
29 | 29 | public class HtmlTreeBuilder extends TreeBuilder {
|
30 | 30 | // tag searches. must be sorted, used in inSorted. HtmlTreeBuilderTest validates they're sorted.
|
31 |
| - static final String[] TagsSearchInScope = new String[]{"applet", "caption", "html", "marquee", "object", "table", "td", "th"}; |
| 31 | + // todo - tag search in scope might need to be properly namespace aware - https://html.spec.whatwg.org/#has-an-element-in-scope |
| 32 | + static final String[] TagsSearchInScope = new String[]{ |
| 33 | + "annotation-xml", "applet", "caption", "desc", "foreignObject", "html", "marquee", "mi", "mn", "mo", "ms", "mtext", "object", "table", "td", "template", "th", "title" // <- svg title |
| 34 | + }; |
32 | 35 | static final String[] TagSearchList = new String[]{"ol", "ul"};
|
33 | 36 | static final String[] TagSearchButton = new String[]{"button"};
|
34 | 37 | static final String[] TagSearchTableScope = new String[]{"html", "table"};
|
@@ -669,11 +672,8 @@ private boolean inSpecificScope(String[] targetNames, String[] baseTypes, @Nulla
|
669 | 672 | final int bottom = stack.size() -1;
|
670 | 673 | final int top = bottom > MaxScopeSearchDepth ? bottom - MaxScopeSearchDepth : 0;
|
671 | 674 | // don't walk too far up the tree
|
672 |
| - |
673 | 675 | for (int pos = bottom; pos >= top; pos--) {
|
674 | 676 | Element el = stack.get(pos);
|
675 |
| - if (!el.tag().namespace().equals(NamespaceHtml)) continue; |
676 |
| - |
677 | 677 | final String elName = el.normalName();
|
678 | 678 | if (inSorted(elName, targetNames))
|
679 | 679 | return true;
|
|
0 commit comments