| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index c5bf0d977708df914299099f36f197a0e5b55eca..36150f73abeebaf479feeca544a2a03bc3da889e 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -4411,7 +4411,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
|
| case 'u': {
|
| Advance(2);
|
| uc32 value;
|
| - if (ParseHexEscape(4, &value)) {
|
| + if (ParseHexEscape(4, &value, true)) {
|
| builder->AddCharacter(value);
|
| } else {
|
| builder->AddCharacter('u');
|
| @@ -4664,11 +4664,15 @@ uc32 RegExpParser::ParseOctalLiteral() {
|
| }
|
|
|
|
|
| -bool RegExpParser::ParseHexEscape(int length, uc32 *value) {
|
| +bool RegExpParser::ParseHexEscape(int length, uc32* value, bool allow_brace) {
|
| int start = position();
|
| uc32 val = 0;
|
| - bool done = false;
|
| - for (int i = 0; !done; i++) {
|
| + bool has_brace = false;
|
| + if (allow_brace && current() == '{') {
|
| + has_brace = true;
|
| + Advance();
|
| + }
|
| + for (int i = 0; i < length; ++i) {
|
| uc32 c = current();
|
| int d = HexValue(c);
|
| if (d < 0) {
|
| @@ -4677,9 +4681,13 @@ bool RegExpParser::ParseHexEscape(int length, uc32 *value) {
|
| }
|
| val = val * 16 + d;
|
| Advance();
|
| - if (i == length - 1) {
|
| - done = true;
|
| + }
|
| + if (has_brace) {
|
| + if (current() != '}') {
|
| + Reset(start);
|
| + return false;
|
| }
|
| + Advance();
|
| }
|
| *value = val;
|
| return true;
|
| @@ -4747,7 +4755,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
|
| case 'u': {
|
| Advance();
|
| uc32 value;
|
| - if (ParseHexEscape(4, &value)) {
|
| + if (ParseHexEscape(4, &value, true)) {
|
| return value;
|
| }
|
| // If \u is not followed by a four-digit hexadecimal, treat it
|
|
|