From 7bffd688c75f42604111ade13b913924cb7d7f02 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 25 Oct 2018 01:24:55 +0800 Subject: [PATCH] fix(parser): allow CRLFs in string interpolations (#8408) fix #8103 --- src/compiler/parser/text-parser.js | 2 +- test/unit/modules/compiler/parser.spec.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser/text-parser.js b/src/compiler/parser/text-parser.js index 284fca33bf4..cf82a62484f 100644 --- a/src/compiler/parser/text-parser.js +++ b/src/compiler/parser/text-parser.js @@ -3,7 +3,7 @@ import { cached } from 'shared/util' import { parseFilters } from './filter-parser' -const defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g +const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g const buildRegex = cached(delimiters => { diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js index 1cdaa3b7171..32c1cc3580b 100644 --- a/test/unit/modules/compiler/parser.spec.js +++ b/test/unit/modules/compiler/parser.spec.js @@ -731,4 +731,10 @@ describe('parser', () => { expect(ast.children[1].isComment).toBe(true) // parse comment with ASTText expect(ast.children[1].text).toBe('comment here') }) + + // #8103 + it('should allow CRLFs in string interpolations', () => { + const ast = parse(`

{{\r\nmsg\r\n}}

`, baseOptions) + expect(ast.children[0].expression).toBe('_s(msg)') + }) })