<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[34863] trunk/src/wp-includes/js/json2.js: External Libraries: update `json2.js` to the `2015-05-03` version.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/34863">34863</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/34863","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-10-06 14:01:52 +0000 (Tue, 06 Oct 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>External Libraries: update `json2.js` to the `2015-05-03` version. Crockford does not tag releases: https://github.com/douglascrockford/JSON-js/commits/master
Props mgibbs189, chriscct7.
Fixes <a href="https://core.trac.wordpress.org/ticket/26913">#26913</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesjsjson2js">trunk/src/wp-includes/js/json2.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesjsjson2js"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/json2.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/json2.js 2015-10-06 13:53:19 UTC (rev 34862)
+++ trunk/src/wp-includes/js/json2.js 2015-10-06 14:01:52 UTC (rev 34863)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- http://www.JSON.org/json2.js
- 2011-02-23
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ json2.js
+ 2015-05-03
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> Public Domain.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,7 +17,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> This file creates a global JSON object containing two methods: stringify
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- and parse.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ and parse. This file is provides the ES5 JSON capability to ES3 systems.
+ If a project might run on IE8 or earlier, then this file should be included.
+ This file does nothing on ES5 systems.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> JSON.stringify(value, replacer, space)
</span><span class="cx" style="display: block; padding: 0 10px"> value any JavaScript value, usually an object or array.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -48,7 +50,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> Date.prototype.toJSON = function (key) {
</span><span class="cx" style="display: block; padding: 0 10px"> function f(n) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Format integers to have at least two digits.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return n < 10 ? '0' + n : n;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return n < 10
+ ? '0' + n
+ : n;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return this.getUTCFullYear() + '-' +
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,8 +98,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> text = JSON.stringify([new Date()], function (key, value) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return this[key] instanceof Date ?
- 'Date(' + this[key] + ')' : value;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return this[key] instanceof Date
+ ? 'Date(' + this[key] + ')'
+ : value;
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> // text is '["Date(---current time---)"]'
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -146,10 +151,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> redistribute.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/*jslint evil: true, strict: false, regexp: false */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*jslint
+ eval, for, this
+*/
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
- call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*property
+ JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
</ins><span class="cx" style="display: block; padding: 0 10px"> getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
</span><span class="cx" style="display: block; padding: 0 10px"> lastIndex, length, parse, prototype, push, replace, slice, stringify,
</span><span class="cx" style="display: block; padding: 0 10px"> test, toJSON, toString, valueOf
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -159,52 +166,53 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Create a JSON object only if one does not already exist. We create the
</span><span class="cx" style="display: block; padding: 0 10px"> // methods in a closure to avoid creating global variables.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-var JSON;
-if (!JSON) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if (typeof JSON !== 'object') {
</ins><span class="cx" style="display: block; padding: 0 10px"> JSON = {};
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> (function () {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "use strict";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'use strict';
+
+ var rx_one = /^[\],:{}\s]*$/,
+ rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
+ rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
+ rx_four = /(?:^|:|,)(?:\s*\[)+/g,
+ rx_escapable = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function f(n) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Format integers to have at least two digits.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return n < 10 ? '0' + n : n;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return n < 10
+ ? '0' + n
+ : n;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ function this_value() {
+ return this.valueOf();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (typeof Date.prototype.toJSON !== 'function') {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- Date.prototype.toJSON = function (key) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ Date.prototype.toJSON = function () {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return isFinite(this.valueOf()) ?
- this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z' : null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return isFinite(this.valueOf())
+ ? this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z'
+ : null;
</ins><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- String.prototype.toJSON =
- Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
- return this.valueOf();
- };
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ Boolean.prototype.toJSON = this_value;
+ Number.prototype.toJSON = this_value;
+ String.prototype.toJSON = this_value;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- gap,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var gap,
</ins><span class="cx" style="display: block; padding: 0 10px"> indent,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- meta = { // table of character substitutions
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- },
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ meta,
</ins><span class="cx" style="display: block; padding: 0 10px"> rep;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -215,12 +223,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Otherwise we must also replace the offending characters with safe escape
</span><span class="cx" style="display: block; padding: 0 10px"> // sequences.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 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);
- }) + '"' : '"' + string + '"';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ rx_escapable.lastIndex = 0;
+ return rx_escapable.test(string)
+ ? '"' + string.replace(rx_escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string'
+ ? c
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"'
+ : '"' + string + '"';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -260,7 +271,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // JSON numbers must be finite. Encode non-finite numbers as null.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return isFinite(value) ? String(value) : 'null';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return isFinite(value)
+ ? String(value)
+ : 'null';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'boolean':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'null':
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -303,9 +316,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Join all of the elements together, separated with commas, and wrap them in
</span><span class="cx" style="display: block; padding: 0 10px"> // brackets.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- v = partial.length === 0 ? '[]' : gap ?
- '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
- '[' + partial.join(',') + ']';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ v = partial.length === 0
+ ? '[]'
+ : gap
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
+ : '[' + partial.join(',') + ']';
</ins><span class="cx" style="display: block; padding: 0 10px"> gap = mind;
</span><span class="cx" style="display: block; padding: 0 10px"> return v;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -319,7 +334,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> k = rep[i];
</span><span class="cx" style="display: block; padding: 0 10px"> v = str(k, value);
</span><span class="cx" style="display: block; padding: 0 10px"> if (v) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- partial.push(quote(k) + (gap ? ': ' : ':') + v);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ partial.push(quote(k) + (
+ gap
+ ? ': '
+ : ':'
+ ) + v);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -331,7 +350,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (Object.prototype.hasOwnProperty.call(value, k)) {
</span><span class="cx" style="display: block; padding: 0 10px"> v = str(k, value);
</span><span class="cx" style="display: block; padding: 0 10px"> if (v) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- partial.push(quote(k) + (gap ? ': ' : ':') + v);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ partial.push(quote(k) + (
+ gap
+ ? ': '
+ : ':'
+ ) + v);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -340,9 +363,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Join all of the member texts together, separated with commas,
</span><span class="cx" style="display: block; padding: 0 10px"> // and wrap them in braces.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- v = partial.length === 0 ? '{}' : gap ?
- '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
- '{' + partial.join(',') + '}';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ v = partial.length === 0
+ ? '{}'
+ : gap
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
+ : '{' + partial.join(',') + '}';
</ins><span class="cx" style="display: block; padding: 0 10px"> gap = mind;
</span><span class="cx" style="display: block; padding: 0 10px"> return v;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -351,6 +376,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // If the JSON object does not yet have a stringify method, give it one.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (typeof JSON.stringify !== 'function') {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"': '\\"',
+ '\\': '\\\\'
+ };
</ins><span class="cx" style="display: block; padding: 0 10px"> JSON.stringify = function (value, replacer, space) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // The stringify method takes a value and an optional replacer, and an optional
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -432,11 +466,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // incorrectly, either silently deleting them, or treating them as line endings.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> text = String(text);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- cx.lastIndex = 0;
- if (cx.test(text)) {
- text = text.replace(cx, function (a) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ rx_dangerous.lastIndex = 0;
+ if (rx_dangerous.test(text)) {
+ text = text.replace(rx_dangerous, function (a) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return '\\u' +
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -453,10 +487,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // we look to see that the remaining characters are only whitespace or ']' or
</span><span class="cx" style="display: block; padding: 0 10px"> // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (/^[\],:{}\s]*$/
- .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (
+ rx_one.test(
+ text
+ .replace(rx_two, '@')
+ .replace(rx_three, ']')
+ .replace(rx_four, '')
+ )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // In the third stage we use the eval function to compile the text into a
</span><span class="cx" style="display: block; padding: 0 10px"> // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -468,8 +506,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // In the optional fourth stage, we recursively walk the new structure, passing
</span><span class="cx" style="display: block; padding: 0 10px"> // each name/value pair to a reviver function for possible transformation.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return typeof reviver === 'function' ?
- walk({'': j}, '') : j;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return typeof reviver === 'function'
+ ? walk({'': j}, '')
+ : j;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If the text is not JSON parseable, then a SyntaxError is thrown.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -477,4 +516,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> throw new SyntaxError('JSON.parse');
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}());
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>