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

Side by Side Diff: src/parser.cc

Issue 6451002: Fix bug in JSON.parse for objects containing "__proto__" as key. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build-ia32
Patch Set: Created 9 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/json.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4040 matching lines...) Expand 10 before | Expand all | Expand 10 after
4051 } 4051 }
4052 Handle<String> key = GetString(); 4052 Handle<String> key = GetString();
4053 if (scanner_.Next() != Token::COLON) { 4053 if (scanner_.Next() != Token::COLON) {
4054 return ReportUnexpectedToken(); 4054 return ReportUnexpectedToken();
4055 } 4055 }
4056 Handle<Object> value = ParseJsonValue(); 4056 Handle<Object> value = ParseJsonValue();
4057 if (value.is_null()) return Handle<Object>::null(); 4057 if (value.is_null()) return Handle<Object>::null();
4058 uint32_t index; 4058 uint32_t index;
4059 if (key->AsArrayIndex(&index)) { 4059 if (key->AsArrayIndex(&index)) {
4060 SetOwnElement(json_object, index, value); 4060 SetOwnElement(json_object, index, value);
4061 } else if (key->Equals(Heap::Proto_symbol())) {
4062 // We can't remove the __proto__ accessor since it's hardcoded
4063 // in several places. Instead go along and add the value as
4064 // the prototype of the created object if possible.
4065 SetPrototype(json_object, value);
4061 } else { 4066 } else {
4062 SetLocalPropertyIgnoreAttributes(json_object, key, value, NONE); 4067 SetLocalPropertyIgnoreAttributes(json_object, key, value, NONE);
4063 } 4068 }
4064 } while (scanner_.Next() == Token::COMMA); 4069 } while (scanner_.Next() == Token::COMMA);
4065 if (scanner_.current_token() != Token::RBRACE) { 4070 if (scanner_.current_token() != Token::RBRACE) {
4066 return ReportUnexpectedToken(); 4071 return ReportUnexpectedToken();
4067 } 4072 }
4068 } 4073 }
4069 return json_object; 4074 return json_object;
4070 } 4075 }
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
5094 info->is_global(), 5099 info->is_global(),
5095 info->StrictMode()); 5100 info->StrictMode());
5096 } 5101 }
5097 } 5102 }
5098 5103
5099 info->SetFunction(result); 5104 info->SetFunction(result);
5100 return (result != NULL); 5105 return (result != NULL);
5101 } 5106 }
5102 5107
5103 } } // namespace v8::internal 5108 } } // namespace v8::internal
OLDNEW
« 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