Skip to content

Commit

Permalink
Properly account for crlf line breaks in readInvalidTemplateToken
Browse files Browse the repository at this point in the history
Issue #1275
  • Loading branch information
marijnh committed Feb 7, 2024
1 parent 6c104c4 commit 2c186ad
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions acorn/src/tokenize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 2c186ad

Please sign in to comment.