Skip to content

Commit aa11b3b

Browse files
authored
Fix parsing of bogus comments after end tags (#507)
1 parent ef7c995 commit aa11b3b

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

html5ever/src/tokenizer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,8 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
862862
let c = get_char!(self, input);
863863
if self.have_appropriate_end_tag() {
864864
match c {
865-
'\t' | '\n' | '\x0C' | ' ' => go!(self: to BeforeAttributeName),
866-
'/' => go!(self: to SelfClosingStartTag),
865+
'\t' | '\n' | '\x0C' | ' ' => go!(self: clear_temp; to BeforeAttributeName),
866+
'/' => go!(self: clear_temp; to SelfClosingStartTag),
867867
'>' => go!(self: clear_temp; emit_tag Data),
868868
_ => (),
869869
}

rcdom/custom-html5lib-tokenizer-tests/regression.test

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,31 @@
3939
{"description": "Windows newline after bogusname",
4040
"input": "&0\r\n",
4141
"output": [["Character", "&0\n"]],
42-
"errors": []}
42+
"errors": []},
43+
44+
{"description": "Bogus comment after end tag with space",
45+
"initialStates": ["Data state", "RCDATA state", "RAWTEXT state", "Script data state"],
46+
"lastStartTag": "style",
47+
"input": "</style ><!a>",
48+
"output": [
49+
["EndTag", "style"],
50+
["Comment", "a"]
51+
],
52+
"errors": [
53+
{"code": "incorrectly-opened-comment"}
54+
]},
55+
56+
{"description": "Bogus comment after end tag with solidus",
57+
"initialStates": ["Data state", "RCDATA state", "RAWTEXT state", "Script data state"],
58+
"lastStartTag": "style",
59+
"input": "</style/><!a>",
60+
"output": [
61+
["EndTag", "style"],
62+
["Comment", "a"]
63+
],
64+
"errors": [
65+
{"code": "unexpected-solidus-in-tag"},
66+
{"code": "incorrectly-opened-comment"}
67+
]}
4368

4469
]}

0 commit comments

Comments
 (0)