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

Side by Side Diff: src/scanner.cc

Issue 700373003: Scanner: disallow unicode escapes in regexp flags. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: test update Created 6 years, 1 month 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 | « src/scanner.h ('k') | test/cctest/test-parsing.cc » ('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 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 // Features shared by parsing and pre-parsing scanners. 5 // Features shared by parsing and pre-parsing scanners.
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1131 }
1132 } 1132 }
1133 Advance(); // consume '/' 1133 Advance(); // consume '/'
1134 1134
1135 literal.Complete(); 1135 literal.Complete();
1136 1136
1137 return true; 1137 return true;
1138 } 1138 }
1139 1139
1140 1140
1141 bool Scanner::ScanLiteralUnicodeEscape() {
1142 DCHECK(c0_ == '\\');
1143 AddLiteralChar(c0_);
1144 Advance();
1145 int hex_digits_read = 0;
1146 if (c0_ == 'u') {
1147 AddLiteralChar(c0_);
1148 while (hex_digits_read < 4) {
1149 Advance();
1150 if (!IsHexDigit(c0_)) break;
1151 AddLiteralChar(c0_);
1152 ++hex_digits_read;
1153 }
1154 }
1155 return hex_digits_read == 4;
1156 }
1157
1158
1159 bool Scanner::ScanRegExpFlags() { 1141 bool Scanner::ScanRegExpFlags() {
1160 // Scan regular expression flags. 1142 // Scan regular expression flags.
1161 LiteralScope literal(this); 1143 LiteralScope literal(this);
1162 while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) { 1144 while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) {
1163 if (c0_ != '\\') { 1145 if (c0_ != '\\') {
1164 AddLiteralCharAdvance(); 1146 AddLiteralCharAdvance();
1165 } else { 1147 } else {
1166 if (!ScanLiteralUnicodeEscape()) { 1148 return false;
1167 return false;
1168 }
1169 Advance();
1170 } 1149 }
1171 } 1150 }
1172 literal.Complete(); 1151 literal.Complete();
1173 1152
1174 next_.location.end_pos = source_pos() - 1; 1153 next_.location.end_pos = source_pos() - 1;
1175 return true; 1154 return true;
1176 } 1155 }
1177 1156
1178 1157
1179 const AstRawString* Scanner::CurrentSymbol(AstValueFactory* ast_value_factory) { 1158 const AstRawString* Scanner::CurrentSymbol(AstValueFactory* ast_value_factory) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 } 1326 }
1348 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); 1327 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u));
1349 } 1328 }
1350 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); 1329 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f));
1351 1330
1352 backing_store_.AddBlock(bytes); 1331 backing_store_.AddBlock(bytes);
1353 return backing_store_.EndSequence().start(); 1332 return backing_store_.EndSequence().start();
1354 } 1333 }
1355 1334
1356 } } // namespace v8::internal 1335 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698