From 1abe20b6da7ad3c279a942afccfd9f278d184b2c Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 25 Jun 2018 11:49:28 +0800 Subject: [PATCH] fix(parser): allow CRLFs in string interpolations, 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 284fca33bf..cf82a62484 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 750e371105..b5c15123ff 100644 --- a/test/unit/modules/compiler/parser.spec.js +++ b/test/unit/modules/compiler/parser.spec.js @@ -717,4 +717,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)') + }) })