[Pkg-javascript-commits] [node-acorn-jsx] 304/484: Only apply kludge from f48503cd31826f8cfb0f0e2b6964879dbe318385 when unicode regexps are not supported
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:47 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit 5d1db2e9937e779bef32e3a91bd0a7ba15367a32
Author: Marijn Haverbeke <marijnh at gmail.com>
Date: Mon Oct 27 10:54:46 2014 +0100
Only apply kludge from f48503cd31826f8cfb0f0e2b6964879dbe318385 when unicode regexps are not supported
---
acorn.js | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/acorn.js b/acorn.js
index efd9e42..a244d10 100644
--- a/acorn.js
+++ b/acorn.js
@@ -912,6 +912,10 @@
finishToken(type, str);
}
+ var regexpUnicodeSupport = false;
+ try { new RegExp("\uffff", "u"); regexpUnicodeSupport = true; }
+ catch(e) {}
+
// Parse a regular expression. Some context-awareness is necessary,
// since a '/' inside a '[]' set does not end the expression.
@@ -939,14 +943,14 @@
var validFlags = /^[gmsiy]*$/;
if (options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;
if (!validFlags.test(mods)) raise(start, "Invalid regular expression flag");
- if (mods.indexOf('u') >= 0) {
+ if (mods.indexOf('u') >= 0 && !regexpUnicodeSupport) {
// Replace each astral symbol and every Unicode code point
// escape sequence that represents such a symbol with a single
// ASCII symbol to avoid throwing on regular expressions that
// are only valid in combination with the `/u` flag.
tmp = tmp
- .replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, 'x')
- .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
+ .replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, "x")
+ .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");
}
}
// Detect invalid regular expressions.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list