From 2c186ade70510bcbc952232dd00a97d19534e129 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 7 Feb 2024 17:52:25 +0100 Subject: [PATCH] Properly account for crlf line breaks in readInvalidTemplateToken Issue https://github.com/acornjs/acorn/issues/1275 --- acorn/src/tokenize.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/acorn/src/tokenize.js b/acorn/src/tokenize.js index 81cf5b9ea..7aa777534 100644 --- a/acorn/src/tokenize.js +++ b/acorn/src/tokenize.js @@ -671,20 +671,18 @@ pp.readInvalidTemplateToken = function() { break case "$": - if (this.input[this.pos + 1] !== "{") { - break - } - - // falls through + if (this.input[this.pos + 1] !== "{") break + // fall through case "`": return this.finishToken(tt.invalidTemplate, this.input.slice(this.start, this.pos)) - case "\r": case "\n": case "\u2028": case "\u2029": + case "\r": + if (this.input[this.pos] + 1 === "\n") ++this.pos + // fall through + case "\n": case "\u2028": case "\u2029": ++this.curLine this.lineStart = this.pos + 1 break - - // no default } } this.raise(this.start, "Unterminated template")