Skip to content

Commit d3634ba

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 3f48926 commit d3634ba

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
@@ -3898,8 +3898,9 @@ private void endTagTemplateInHead() throws SAXException {
38983898

38993899
private int findLastInTableScopeOrRootTemplateTbodyTheadTfoot() {
39003900
for (int i = currentPtr; i > 0; i--) {
3901-
if (stack[i].getGroup() == TreeBuilder.TBODY_OR_THEAD_OR_TFOOT ||
3902-
stack[i].getGroup() == TreeBuilder.TEMPLATE) {
3901+
if (stack[i].ns == "http://www.w3.org/1999/xhtml"
3902+
&& (stack[i].getGroup() == TreeBuilder.TBODY_OR_THEAD_OR_TFOOT
3903+
|| stack[i].getGroup() == TreeBuilder.TEMPLATE)) {
39033904
return i;
39043905
}
39053906
}
@@ -4667,7 +4668,7 @@ private int findLastOrRoot(@Local String name) {
46674668

46684669
private int findLastOrRoot(int group) {
46694670
for (int i = currentPtr; i > 0; i--) {
4670-
if (stack[i].getGroup() == group) {
4671+
if (stack[i].ns == "http://www.w3.org/1999/xhtml" && stack[i].getGroup() == group) {
46714672
return i;
46724673
}
46734674
}

0 commit comments

Comments
 (0)