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

Side by Side Diff: src/json-parser.h

Issue 936613006: The expected key is a valid identifier, which is already free of \\, <0x20, ". (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_JSON_PARSER_H_ 5 #ifndef V8_JSON_PARSER_H_
6 #define V8_JSON_PARSER_H_ 6 #define V8_JSON_PARSER_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/char-predicates-inl.h" 10 #include "src/char-predicates-inl.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 int length = expected->length(); 101 int length = expected->length();
102 if (source_->length() - position_ - 1 > length) { 102 if (source_->length() - position_ - 1 > length) {
103 DisallowHeapAllocation no_gc; 103 DisallowHeapAllocation no_gc;
104 String::FlatContent content = expected->GetFlatContent(); 104 String::FlatContent content = expected->GetFlatContent();
105 if (content.IsOneByte()) { 105 if (content.IsOneByte()) {
106 DCHECK_EQ('"', c0_); 106 DCHECK_EQ('"', c0_);
107 const uint8_t* input_chars = seq_source_->GetChars() + position_ + 1; 107 const uint8_t* input_chars = seq_source_->GetChars() + position_ + 1;
108 const uint8_t* expected_chars = content.ToOneByteVector().start(); 108 const uint8_t* expected_chars = content.ToOneByteVector().start();
109 for (int i = 0; i < length; i++) { 109 for (int i = 0; i < length; i++) {
110 uint8_t c0 = input_chars[i]; 110 uint8_t c0 = input_chars[i];
111 if (c0 != expected_chars[i] || 111 // The expected string has to be free of \, " and characters < 0x20.
112 c0 == '"' || c0 < 0x20 || c0 == '\\') { 112 if (c0 != expected_chars[i]) return false;
113 return false;
114 }
115 } 113 }
116 if (input_chars[length] == '"') { 114 if (input_chars[length] == '"') {
117 position_ = position_ + length + 1; 115 position_ = position_ + length + 1;
118 AdvanceSkipWhitespace(); 116 AdvanceSkipWhitespace();
119 return true; 117 return true;
120 } 118 }
121 } 119 }
122 } 120 }
123 return false; 121 return false;
124 } 122 }
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 808
811 DCHECK_EQ('"', c0_); 809 DCHECK_EQ('"', c0_);
812 // Advance past the last '"'. 810 // Advance past the last '"'.
813 AdvanceSkipWhitespace(); 811 AdvanceSkipWhitespace();
814 return result; 812 return result;
815 } 813 }
816 814
817 } } // namespace v8::internal 815 } } // namespace v8::internal
818 816
819 #endif // V8_JSON_PARSER_H_ 817 #endif // V8_JSON_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698