Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1521)

Unified Diff: src/js/json.js

Issue 1506933003: JSON.parse: properly deal with reviver result (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/json.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/json.js
diff --git a/src/js/json.js b/src/js/json.js
index 38c46af6d617f41332126f6195cbb45e8c553958..1ed106db25eb3e35bb3164ae0ba1bc1d0c1cc8f8 100644
--- a/src/js/json.js
+++ b/src/js/json.js
@@ -28,19 +28,24 @@ utils.Import(function(from) {
// -------------------------------------------------------------------
-function Revive(holder, name, reviver) {
+function InternalizeJSONProperty(holder, name, reviver) {
var val = holder[name];
if (IS_OBJECT(val)) {
if (IS_ARRAY(val)) {
Yang 2015/12/08 14:21:54 I thought IS_ARRAY is not the same as IsArray from
var length = val.length;
for (var i = 0; i < length; i++) {
- var newElement = Revive(val, %_NumberToString(i), reviver);
- val[i] = newElement;
+ var newElement =
+ InternalizeJSONProperty(val, %_NumberToString(i), reviver);
+ if (IS_UNDEFINED(newElement)) {
+ delete val[i];
+ } else {
+ val[i] = newElement;
Yang 2015/12/08 14:21:54 is this equivalent to CreateDataProperty? What if
adamk 2015/12/09 23:49:20 What was the response to this comment? Perhaps thi
+ }
}
} else {
for (var p in val) {
if (HAS_OWN_PROPERTY(val, p)) {
- var newElement = Revive(val, p, reviver);
+ var newElement = InternalizeJSONProperty(val, p, reviver);
if (IS_UNDEFINED(newElement)) {
delete val[p];
} else {
@@ -57,7 +62,7 @@ function Revive(holder, name, reviver) {
function JSONParse(text, reviver) {
var unfiltered = %ParseJson(text);
if (IS_CALLABLE(reviver)) {
- return Revive({'': unfiltered}, '', reviver);
+ return InternalizeJSONProperty({'': unfiltered}, '', reviver);
} else {
return unfiltered;
}
« no previous file with comments | « no previous file | test/mjsunit/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698