Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions src/nu/validator/htmlparser/impl/TreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,9 @@ public final void startTag(ElementName elementName,
reconstructTheActiveFormattingElements();
if (TreeBuilder.NOT_FOUND_ON_STACK != findLastInScope("nobr")) {
errFooSeenWhenFooOpen(name);
adoptionAgencyEndTag("nobr");
if (!adoptionAgencyEndTag("nobr")) {
anyOtherEndTagInBody("nobr");
}
reconstructTheActiveFormattingElements();
}
appendToCurrentNodeAndPushFormattingElementMayFoster(
Expand Down Expand Up @@ -3695,30 +3697,8 @@ public final void endTag(ElementName elementName) throws SAXException {
// else handle like any other tag
// CPPONLY: MOZ_FALLTHROUGH;
default:
if (isCurrent(name)) {
pop();
break endtagloop;
}

eltPos = currentPtr;
for (;;) {
StackNode<T> node = stack[eltPos];
if (node.ns == "http://www.w3.org/1999/xhtml" && node.name == name) {
generateImpliedEndTags();
if (errorHandler != null
&& !isCurrent(name)) {
errUnclosedElements(eltPos, name);
}
while (currentPtr >= eltPos) {
pop();
}
break endtagloop;
} else if (eltPos == 0 || node.isSpecial()) {
errStrayEndTag(name);
break endtagloop;
}
eltPos--;
}
anyOtherEndTagInBody(name);
break endtagloop;
}
// CPPONLY: MOZ_FALLTHROUGH;
case IN_HEAD:
Expand Down Expand Up @@ -4433,6 +4413,36 @@ private void removeFromListOfActiveFormattingElements(int pos) {
listPtr--;
}

/**
* The "any other end tag" entry of the "in body" insertion mode.
*/
private void anyOtherEndTagInBody(@Local String name) throws SAXException {
if (isCurrent(name)) {
pop();
return;
}

int eltPos = currentPtr;
for (;;) {
StackNode<T> node = stack[eltPos];
if (node.ns == "http://www.w3.org/1999/xhtml" && node.name == name) {
generateImpliedEndTags();
if (errorHandler != null
&& !isCurrent(name)) {
errUnclosedElements(eltPos, name);
}
while (currentPtr >= eltPos) {
pop();
}
return;
} else if (eltPos == 0 || node.isSpecial()) {
errStrayEndTag(name);
return;
}
eltPos--;
}
}

/**
* Adoption agency algorithm.
*
Expand Down
Loading