Skip to content

Commit

Permalink
fix(tokenizer): Fix parsing special closing tags (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Mar 7, 2021
1 parent 2461517 commit 214ab08
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,12 @@ export default class Tokenizer {
} else if (c === ">") {
this._state = State.Text;
} else if (this.special !== Special.None) {
if (c === "s" || c === "S") {
if (this.special !== Special.Title && (c === "s" || c === "S")) {
this._state = State.BeforeSpecialSEnd;
} else if (c === "t" || c === "T") {
} else if (
this.special === Special.Title &&
(c === "t" || c === "T")
) {
this._state = State.BeforeSpecialTEnd;
} else {
this._state = State.Text;
Expand Down
22 changes: 22 additions & 0 deletions src/__fixtures__/Events/39-title-in-script.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "</title> in <script> (#745)",
"html": "<script>'</title>'</script>",
"expected": [
{
"event": "opentagname",
"data": ["script"]
},
{
"event": "opentag",
"data": ["script", {}]
},
{
"event": "text",
"data": ["'</title>'"]
},
{
"event": "closetag",
"data": ["script"]
}
]
}

0 comments on commit 214ab08

Please sign in to comment.