fix: allow quotes in inline comment tag, fixes #628

This commit is contained in:
Jun Yang
2023-07-07 22:48:55 +08:00
committed by GitHub
parent c0bc2de76e
commit bf425c3adb
5 changed files with 38 additions and 12 deletions
-9
View File
@@ -199,15 +199,6 @@ describe('Tokenizer', function () {
})
})
describe('#readTagToken()', () => {
it('should skip quoted delimiters', function () {
const html = '{% assign a = "%} {% }} {{" %}'
const tokenizer = new Tokenizer(html)
const token = tokenizer.readTagToken()
expect(token).toBeInstanceOf(TagToken)
expect(token.name).toBe('assign')
expect(token.args).toBe('a = "%} {% }} {{"')
})
})
describe('#readOutputToken()', () => {
it('should skip quoted delimiters', function () {
+4 -3
View File
@@ -140,9 +140,10 @@ export class Tokenizer {
return token
}
readToDelimiter (delimiter: string) {
readToDelimiter (delimiter: string, respectQuoted = false) {
this.skipBlank()
while (this.p < this.N) {
if ((this.peekType() & QUOTE)) {
if (respectQuoted && (this.peekType() & QUOTE)) {
this.readQuoted()
continue
}
@@ -156,7 +157,7 @@ export class Tokenizer {
const { file, input } = this
const { outputDelimiterRight } = options
const begin = this.p
if (this.readToDelimiter(outputDelimiterRight) === -1) {
if (this.readToDelimiter(outputDelimiterRight, true) === -1) {
throw this.error(`output ${this.snapshot(begin)} not closed`, begin)
}
return new OutputToken(input, begin, this.p, options, file)