Commit 9b74675e authored by dslomov@chromium.org's avatar dslomov@chromium.org

Check string literals with escapes in PreParserTraits::GetSymbol()

LOG=Y
BUG=v8:3606
R=arv@chromium.org, marja@chromium.org

Review URL: https://codereview.chromium.org/615813004

Patch from Caitlin Potter <caitpotter88@gmail.com>.

Cr-Commit-Position: refs/heads/master@{#24880}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24880 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 99124866
......@@ -59,10 +59,10 @@ PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) {
if (scanner->UnescapedLiteralMatches("arguments", 9)) {
return PreParserIdentifier::Arguments();
}
if (scanner->UnescapedLiteralMatches("prototype", 9)) {
if (scanner->LiteralMatches("prototype", 9)) {
return PreParserIdentifier::Prototype();
}
if (scanner->UnescapedLiteralMatches("constructor", 11)) {
if (scanner->LiteralMatches("constructor", 11)) {
return PreParserIdentifier::Constructor();
}
return PreParserIdentifier::Default();
......
......@@ -394,16 +394,20 @@ class Scanner {
const AstRawString* NextSymbol(AstValueFactory* ast_value_factory);
double DoubleValue();
bool UnescapedLiteralMatches(const char* data, int length) {
bool LiteralMatches(const char* data, int length, bool allow_escapes = true) {
if (is_literal_one_byte() &&
literal_length() == length &&
!literal_contains_escapes()) {
(allow_escapes || !literal_contains_escapes())) {
const char* token =
reinterpret_cast<const char*>(literal_one_byte_string().start());
return !strncmp(token, data, length);
}
return false;
}
inline bool UnescapedLiteralMatches(const char* data, int length) {
return LiteralMatches(data, length, false);
}
void IsGetOrSet(bool* is_get, bool* is_set) {
if (is_literal_one_byte() &&
literal_length() == 3 &&
......
......@@ -3973,6 +3973,13 @@ TEST(ClassStaticPrototypeErrors) {
"static get prototype() {}",
"static set prototype(_) {}",
"static *prototype() {}",
"static 'prototype'() {}",
"static *'prototype'() {}",
"static prot\\u006ftype() {}",
"static 'prot\\u006ftype'() {}",
"static get 'prot\\u006ftype'() {}",
"static set 'prot\\u006ftype'(_) {}",
"static *'prot\\u006ftype'() {}",
NULL};
static const ParserFlag always_flags[] = {
......@@ -3993,6 +4000,13 @@ TEST(ClassSpecialConstructorErrors) {
"get constructor() {}",
"get constructor(_) {}",
"*constructor() {}",
"get 'constructor'() {}",
"*'constructor'() {}",
"get c\\u006fnstructor() {}",
"*c\\u006fnstructor() {}",
"get 'c\\u006fnstructor'() {}",
"get 'c\\u006fnstructor'(_) {}",
"*'c\\u006fnstructor'() {}",
NULL};
static const ParserFlag always_flags[] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment