Skip to content

Commit 2866a09

Browse files
Ensure namespace-aware “clear the stack” handling
This change ensures that for all cases with spec requirements in the form “clear the stack back to a foo context” — which involves checking for elements with particular names — we only look for elements in the HTML namespace, rather than additionally looking for elements which aren’t in the HTML namespace but that also have those particular names. Otherwise, without this change, we aren’t in conformance with the spec requirements, and we fail several cases in the html5lib-tests suite. Fixes #33
1 parent 92f35a3 commit 2866a09

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/nu/validator/htmlparser/impl/TreeBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,8 +3907,9 @@ private void endTagTemplateInHead() throws SAXException {
39073907

39083908
private int findLastInTableScopeOrRootTemplateTbodyTheadTfoot() {
39093909
for (int i = currentPtr; i > 0; i--) {
3910-
if (stack[i].getGroup() == TreeBuilder.TBODY_OR_THEAD_OR_TFOOT ||
3911-
stack[i].getGroup() == TreeBuilder.TEMPLATE) {
3910+
if (stack[i].ns == "http://www.w3.org/1999/xhtml"
3911+
&& (stack[i].getGroup() == TreeBuilder.TBODY_OR_THEAD_OR_TFOOT
3912+
|| stack[i].getGroup() == TreeBuilder.TEMPLATE)) {
39123913
return i;
39133914
}
39143915
}
@@ -4699,7 +4700,7 @@ private int findLastOrRoot(@Local String name) {
46994700

47004701
private int findLastOrRoot(int group) {
47014702
for (int i = currentPtr; i > 0; i--) {
4702-
if (stack[i].getGroup() == group) {
4703+
if (stack[i].ns == "http://www.w3.org/1999/xhtml" && stack[i].getGroup() == group) {
47034704
return i;
47044705
}
47054706
}

0 commit comments

Comments
 (0)