From 01a338310cb703088568aefcb2ba4f349b2fa19d Mon Sep 17 00:00:00 2001
From: Haoqun Jiang <haoqunjiang@gmail.com>
Date: Thu, 28 Feb 2019 23:34:14 +0800
Subject: [PATCH] fix: avoid compression of unicode sequences by using regexps

closes #9456
---
 src/compiler/parser/html-parser.js | 4 ++--
 src/core/util/lang.js              | 4 ++--
 src/core/util/options.js           | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/compiler/parser/html-parser.js b/src/compiler/parser/html-parser.js
index 3139721c366..b574e9c40ed 100644
--- a/src/compiler/parser/html-parser.js
+++ b/src/compiler/parser/html-parser.js
@@ -11,12 +11,12 @@
 
 import { makeMap, no } from 'shared/util'
 import { isNonPhrasingTag } from 'web/compiler/util'
-import { unicodeLetters } from 'core/util/lang'
+import { unicodeRegExp } from 'core/util/lang'
 
 // Regular Expressions for parsing tags and attributes
 const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/
 const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/
-const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeLetters}]*`
+const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`
 const qnameCapture = `((?:${ncname}\\:)?${ncname})`
 const startTagOpen = new RegExp(`^<${qnameCapture}`)
 const startTagClose = /^\s*(\/?)>/
diff --git a/src/core/util/lang.js b/src/core/util/lang.js
index b9026762506..89436944d39 100644
--- a/src/core/util/lang.js
+++ b/src/core/util/lang.js
@@ -5,7 +5,7 @@
  * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  */
-export const unicodeLetters = 'a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD'
+export const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/
 
 /**
  * Check if a string starts with $ or _
@@ -30,7 +30,7 @@ export function def (obj: Object, key: string, val: any, enumerable?: boolean) {
 /**
  * Parse simple path.
  */
-const bailRE = new RegExp(`[^${unicodeLetters}.$_\\d]`)
+const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`)
 export function parsePath (path: string): any {
   if (bailRE.test(path)) {
     return
diff --git a/src/core/util/options.js b/src/core/util/options.js
index 20aba22709b..243567859de 100644
--- a/src/core/util/options.js
+++ b/src/core/util/options.js
@@ -3,7 +3,7 @@
 import config from '../config'
 import { warn } from './debug'
 import { set } from '../observer/index'
-import { unicodeLetters } from './lang'
+import { unicodeRegExp } from './lang'
 import { nativeWatch, hasSymbol } from './env'
 
 import {
@@ -277,7 +277,7 @@ function checkComponents (options: Object) {
 }
 
 export function validateComponentName (name: string) {
-  if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeLetters}]*$`).test(name)) {
+  if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
     warn(
       'Invalid component name: "' + name + '". Component names ' +
       'should conform to valid custom element name in html5 specification.'