Revision: 6802 Author: [email protected] Date: Wed Feb 16 00:10:47 2011 Log: Fix bug 1137. No longer allow the RegExp /(*)/.
BUG=v8:1137 TEST=test/mjsunit/regexp.js Review URL: http://codereview.chromium.org/6499016 http://code.google.com/p/v8/source/detail?r=6802 Modified: /branches/bleeding_edge/src/parser.cc /branches/bleeding_edge/test/mjsunit/regexp.js ======================================= --- /branches/bleeding_edge/src/parser.cc Mon Feb 14 10:44:26 2011 +++ /branches/bleeding_edge/src/parser.cc Wed Feb 16 00:10:47 2011 @@ -4273,6 +4273,8 @@ capture_index); } builder->AddAtom(body); + // For compatability with JSC and ES3, we allow quantifiers after + // lookaheads, and break in all cases. break; } case '|': { @@ -4346,7 +4348,7 @@ type, captures_started()); builder = stored_state->builder(); - break; + continue; } case '[': { RegExpTree* atom = ParseCharacterClass(CHECK_FAILED); @@ -4369,11 +4371,11 @@ builder->AddAssertion( new RegExpAssertion(RegExpAssertion::NON_BOUNDARY)); continue; - // AtomEscape :: - // CharacterClassEscape - // - // CharacterClassEscape :: one of - // d D s S w W + // AtomEscape :: + // CharacterClassEscape + // + // CharacterClassEscape :: one of + // d D s S w W case 'd': case 'D': case 's': case 'S': case 'w': case 'W': { uc32 c = Next(); Advance(2); ======================================= --- /branches/bleeding_edge/test/mjsunit/regexp.js Fri Jan 7 04:35:42 2011 +++ /branches/bleeding_edge/test/mjsunit/regexp.js Wed Feb 16 00:10:47 2011 @@ -676,3 +676,17 @@ assertFalse(re.test("c")); assertFalse(re.test("")); +// Valid syntax in ES5. +re = RegExp("(?:x)*"); +re = RegExp("(x)*"); + +// Syntax extension relative to ES5, for matching JSC (and ES3). +// Shouldn't throw. +re = RegExp("(?=x)*"); +re = RegExp("(?!x)*"); + +// Should throw. Shouldn't hit asserts in debug mode. +assertThrows("RegExp('(*)')"); +assertThrows("RegExp('(?:*)')"); +assertThrows("RegExp('(?=*)')"); +assertThrows("RegExp('(?!*)')"); -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
