Browse Source

Use def_prop instead of put_prop in JSON.parse()

With put_prop variant Duktape would incorrectly parse a JSON object
containing a '__proto__' named property.  Such a property must be
parsed as a plain property and must not affect the object's prototype
(ES6 inherited __proto__ property).
pull/20/head
Sami Vaarala 11 years ago
parent
commit
6516d0d3a5
  1. 4
      src/duk_bi_json.c

4
src/duk_bi_json.c

@ -537,7 +537,7 @@ static void duk__dec_object(duk_json_dec_ctx *js_ctx) {
/* [ ... obj key val ] */
duk_put_prop(ctx, -3);
duk_def_prop_wec(ctx, -3);
/* [ ... obj ] */
@ -600,7 +600,7 @@ static void duk__dec_array(duk_json_dec_ctx *js_ctx) {
/* [ ... arr val ] */
duk_put_prop_index(ctx, -2, arr_idx);
duk_def_prop_index_wec(ctx, -2, arr_idx);
arr_idx++;
}

Loading…
Cancel
Save