Skip to content

Commit f5c4147

Browse files
keithamushsivonen
authored andcommitted
Mozilla bug 2049083 - Ensure nobr follows "any other end tag"
1 parent 1d7aa7d commit f5c4147

1 file changed

Lines changed: 35 additions & 25 deletions

File tree

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

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,9 @@ public final void startTag(ElementName elementName,
20812081
reconstructTheActiveFormattingElements();
20822082
if (TreeBuilder.NOT_FOUND_ON_STACK != findLastInScope("nobr")) {
20832083
errFooSeenWhenFooOpen(name);
2084-
adoptionAgencyEndTag("nobr");
2084+
if (!adoptionAgencyEndTag("nobr")) {
2085+
anyOtherEndTagInBody("nobr");
2086+
}
20852087
reconstructTheActiveFormattingElements();
20862088
}
20872089
appendToCurrentNodeAndPushFormattingElementMayFoster(
@@ -3695,30 +3697,8 @@ public final void endTag(ElementName elementName) throws SAXException {
36953697
// else handle like any other tag
36963698
// CPPONLY: MOZ_FALLTHROUGH;
36973699
default:
3698-
if (isCurrent(name)) {
3699-
pop();
3700-
break endtagloop;
3701-
}
3702-
3703-
eltPos = currentPtr;
3704-
for (;;) {
3705-
StackNode<T> node = stack[eltPos];
3706-
if (node.ns == "http://www.w3.org/1999/xhtml" && node.name == name) {
3707-
generateImpliedEndTags();
3708-
if (errorHandler != null
3709-
&& !isCurrent(name)) {
3710-
errUnclosedElements(eltPos, name);
3711-
}
3712-
while (currentPtr >= eltPos) {
3713-
pop();
3714-
}
3715-
break endtagloop;
3716-
} else if (eltPos == 0 || node.isSpecial()) {
3717-
errStrayEndTag(name);
3718-
break endtagloop;
3719-
}
3720-
eltPos--;
3721-
}
3700+
anyOtherEndTagInBody(name);
3701+
break endtagloop;
37223702
}
37233703
// CPPONLY: MOZ_FALLTHROUGH;
37243704
case IN_HEAD:
@@ -4433,6 +4413,36 @@ private void removeFromListOfActiveFormattingElements(int pos) {
44334413
listPtr--;
44344414
}
44354415

4416+
/**
4417+
* The "any other end tag" entry of the "in body" insertion mode.
4418+
*/
4419+
private void anyOtherEndTagInBody(@Local String name) throws SAXException {
4420+
if (isCurrent(name)) {
4421+
pop();
4422+
return;
4423+
}
4424+
4425+
int eltPos = currentPtr;
4426+
for (;;) {
4427+
StackNode<T> node = stack[eltPos];
4428+
if (node.ns == "http://www.w3.org/1999/xhtml" && node.name == name) {
4429+
generateImpliedEndTags();
4430+
if (errorHandler != null
4431+
&& !isCurrent(name)) {
4432+
errUnclosedElements(eltPos, name);
4433+
}
4434+
while (currentPtr >= eltPos) {
4435+
pop();
4436+
}
4437+
return;
4438+
} else if (eltPos == 0 || node.isSpecial()) {
4439+
errStrayEndTag(name);
4440+
return;
4441+
}
4442+
eltPos--;
4443+
}
4444+
}
4445+
44364446
/**
44374447
* Adoption agency algorithm.
44384448
*

0 commit comments

Comments
 (0)