summaryrefslogtreecommitdiff
path: root/deps/v8/test/webkit/resources/json2-es5-compat.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/webkit/resources/json2-es5-compat.js')
-rw-r--r--deps/v8/test/webkit/resources/json2-es5-compat.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/deps/v8/test/webkit/resources/json2-es5-compat.js b/deps/v8/test/webkit/resources/json2-es5-compat.js
index b71656f007..82146ca6a4 100644
--- a/deps/v8/test/webkit/resources/json2-es5-compat.js
+++ b/deps/v8/test/webkit/resources/json2-es5-compat.js
@@ -186,7 +186,7 @@ if (!this.JSON) {
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- escapable = /[\\\"\x00-\x1f]/g,
+ escapable = /[\\\"\x00-\x1F]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,
gap,
indent,
meta = { // table of character substitutions
@@ -203,17 +203,17 @@ if (!this.JSON) {
function quote(string) {
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can safely slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe escape
-// sequences.
+// If the string contains no control characters, no quote characters, no
+// backslash characters, and no lone surrogates, then we can safely
+// slap some quotes around it. Otherwise we must also replace the
+// offending characters with safe escape sequences.
escapable.lastIndex = 0;
return escapable.test(string) ?
'"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string' ? c :
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ '\\u' + a.charCodeAt(0).toString(16).padStart(4, '0');
}) + '"' :
'"' + string + '"';
}