Skip to content

Commit ef094ba

Browse files
committed
select can not contain arbitrary elements; input closes selects
1 parent 9b6ed12 commit ef094ba

23 files changed

Lines changed: 100 additions & 47 deletions

src/main/java/org/htmlunit/cyberneko/HTMLElements.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public HTMLElements() {
357357

358358
new Element(IMAGE, "IMAGE", Element.EMPTY, BODY, null),
359359
// INPUT - O EMPTY
360-
new Element(INPUT, "INPUT", Element.EMPTY, BODY, null),
360+
new Element(INPUT, "INPUT", Element.EMPTY, BODY, new short[]{SELECT}),
361361
// INS - - (%flow;)*
362362
new Element(INS, "INS", Element.INLINE, BODY, null),
363363
};

src/main/java/org/htmlunit/cyberneko/HTMLTagBalancer.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,6 @@ public void startElement(final QName elem, XMLAttributes attrs, final Augmentati
679679
notifyDiscardedStartElement(elem, attrs, augs);
680680
return;
681681
}
682-
else if (elementCode != HTMLElements.OPTION
683-
&& elementCode != HTMLElements.OPTGROUP
684-
&& elementCode != HTMLElements.HR
685-
&& !element.isScriptSupporting()) {
686-
notifyDiscardedStartElement(elem, attrs, augs);
687-
return;
688-
}
689682
}
690683

691684
if (elementCode == HTMLElements.HTML && !isForcedCreation) {
@@ -1140,13 +1133,6 @@ public void endElement(final QName element, final Augmentations augs) throws XNI
11401133
if (elementCode == HTMLElements.SELECT) {
11411134
fOpenedSelect = false;
11421135
}
1143-
else if (elementCode != HTMLElements.OPTION
1144-
&& elementCode != HTMLElements.OPTGROUP
1145-
&& elementCode != HTMLElements.HR
1146-
&& !elem.isScriptSupporting()) {
1147-
notifyDiscardedEndElement(element, augs);
1148-
return;
1149-
}
11501136
}
11511137

11521138
if (elementCode == HTMLElements.TEMPLATE) {

src/test/resources/org/htmlunit/cyberneko/testfiles/select/test-select-containing-a.html.canonical

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
)head
44
(body
55
(select
6+
(a
7+
Ahref abc
68
"anchor
9+
)a
710
)select
811
)body
912
)html
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
(select
2+
(a
3+
Ahref abc
24
"anchor
3-
)select
5+
)a
6+
)select
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<html><head></head><body><select>anchor</select></body></html>
1+
<html><head></head><body><select><a href="abc">anchor</a></select></body></html>

src/test/resources/org/htmlunit/cyberneko/testfiles/select/test-select-containing-a.html.canonical-xni

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ startElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml"
44
endElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
55
startElement (localpart="body",rawname="body",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
66
startElement (localpart="select",rawname="select") [(1,1,0) (1,9,8) false]
7+
startElement (localpart="a",rawname="a") [(1,9,8) (1,23,22) false]
78
characters 'anchor'[(1,23,22) (1,29,28) false]
9+
endElement (localpart="a",rawname="a") [(1,29,28) (1,33,32) false]
810
endElement (localpart="select",rawname="select") [(1,33,32) (1,42,41) false]
911
characters '
1012
'[(1,42,41) (2,1,42) false]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<select><button>

src/test/resources/org/htmlunit/cyberneko/testfiles/select/test-select-containing-a.html.canonical-sax-cust renamed to src/test/resources/org/htmlunit/cyberneko/testfiles/select/test-select-containing-button.html.canonical

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
)head
44
(body
55
(select
6-
x(a
7-
Ahref abc
8-
"anchor
9-
x)a
6+
(button
7+
)button
108
)select
119
)body
1210
)html
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(select
2+
(button
3+
)button
4+
)select
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<html><head></head><body><select><button></button></select></body></html>

0 commit comments

Comments
 (0)