From 568e1d67e5f255a3b66fd8fbe81d84941c84478f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= Date: Sun, 7 Mar 2021 11:17:21 -0800 Subject: [PATCH] fix(tokenizer): Fix parsing special closing tags --- src/Tokenizer.ts | 7 ++++-- .../Events/39-title-in-script.json | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/__fixtures__/Events/39-title-in-script.json diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts index 2d12808f7..c613da297 100644 --- a/src/Tokenizer.ts +++ b/src/Tokenizer.ts @@ -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; diff --git a/src/__fixtures__/Events/39-title-in-script.json b/src/__fixtures__/Events/39-title-in-script.json new file mode 100644 index 000000000..1a45c244a --- /dev/null +++ b/src/__fixtures__/Events/39-title-in-script.json @@ -0,0 +1,22 @@ +{ + "name": " in ", + "expected": [ + { + "event": "opentagname", + "data": ["script"] + }, + { + "event": "opentag", + "data": ["script", {}] + }, + { + "event": "text", + "data": ["''"] + }, + { + "event": "closetag", + "data": ["script"] + } + ] +}