Fix bug 1137. No longer allow the RegExp /(*)/.
BUG=v8:1137 TEST=test/mjsunit/regexp.js Review URL: http://codereview.chromium.org/6499016 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6802 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
316a12dea9
commit
9ec16dfe68
@ -4273,6 +4273,8 @@ RegExpTree* RegExpParser::ParseDisjunction() {
|
|||||||
capture_index);
|
capture_index);
|
||||||
}
|
}
|
||||||
builder->AddAtom(body);
|
builder->AddAtom(body);
|
||||||
|
// For compatability with JSC and ES3, we allow quantifiers after
|
||||||
|
// lookaheads, and break in all cases.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '|': {
|
case '|': {
|
||||||
@ -4346,7 +4348,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
|
|||||||
type,
|
type,
|
||||||
captures_started());
|
captures_started());
|
||||||
builder = stored_state->builder();
|
builder = stored_state->builder();
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
case '[': {
|
case '[': {
|
||||||
RegExpTree* atom = ParseCharacterClass(CHECK_FAILED);
|
RegExpTree* atom = ParseCharacterClass(CHECK_FAILED);
|
||||||
@ -4369,11 +4371,11 @@ RegExpTree* RegExpParser::ParseDisjunction() {
|
|||||||
builder->AddAssertion(
|
builder->AddAssertion(
|
||||||
new RegExpAssertion(RegExpAssertion::NON_BOUNDARY));
|
new RegExpAssertion(RegExpAssertion::NON_BOUNDARY));
|
||||||
continue;
|
continue;
|
||||||
// AtomEscape ::
|
// AtomEscape ::
|
||||||
// CharacterClassEscape
|
// CharacterClassEscape
|
||||||
//
|
//
|
||||||
// CharacterClassEscape :: one of
|
// CharacterClassEscape :: one of
|
||||||
// d D s S w W
|
// d D s S w W
|
||||||
case 'd': case 'D': case 's': case 'S': case 'w': case 'W': {
|
case 'd': case 'D': case 's': case 'S': case 'w': case 'W': {
|
||||||
uc32 c = Next();
|
uc32 c = Next();
|
||||||
Advance(2);
|
Advance(2);
|
||||||
|
@ -676,3 +676,17 @@ assertEquals(["bc"], re.exec("zimzomzumbc"));
|
|||||||
assertFalse(re.test("c"));
|
assertFalse(re.test("c"));
|
||||||
assertFalse(re.test(""));
|
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('(?!*)')");
|
||||||
|
Loading…
Reference in New Issue
Block a user