Skip to content

Commit 6c124b3

Browse files
sideshowbarkerhsivonen
authored andcommitted
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 9d72e92 commit 6c124b3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -3905,8 +3905,9 @@ private void endTagTemplateInHead() throws SAXException {
39053905

39063906
private int findLastInTableScopeOrRootTemplateTbodyTheadTfoot() {
39073907
for (int i = currentPtr; i > 0; i--) {
3908-
if (stack[i].getGroup() == TreeBuilder.TBODY_OR_THEAD_OR_TFOOT ||
3909-
stack[i].getGroup() == TreeBuilder.TEMPLATE) {
3908+
if (stack[i].ns == "http://www.w3.org/1999/xhtml"
3909+
&& (stack[i].getGroup() == TreeBuilder.TBODY_OR_THEAD_OR_TFOOT
3910+
|| stack[i].getGroup() == TreeBuilder.TEMPLATE)) {
39103911
return i;
39113912
}
39123913
}
@@ -4697,7 +4698,7 @@ private int findLastOrRoot(@Local String name) {
46974698

46984699
private int findLastOrRoot(int group) {
46994700
for (int i = currentPtr; i > 0; i--) {
4700-
if (stack[i].getGroup() == group) {
4701+
if (stack[i].ns == "http://www.w3.org/1999/xhtml" && stack[i].getGroup() == group) {
47014702
return i;
47024703
}
47034704
}

0 commit comments

Comments
 (0)