Bug 16752
Summary: | backreferences to nonexistent subexpressions should raise according to ES3 | ||
---|---|---|---|
Product: | WebKit | Reporter: | Eric Seidel (no email) <eric> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | barraclough, darin, ian, jwalden+bwo |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Mac | ||
OS: | OS X 10.4 |
Eric Seidel (no email)
back-references to non-existent selectors should raise (acid3 bug)
function () {
// test 86: Regular Expressions
var ok = true;
try {
eval("/TA[])]/.exec('TA]')");
// JS regexps aren't like Perl regexps, if their character
// classes start with a ] that means they're empty. So this
// is a syntax error; if we get here it's a bug.
ok = false;
} catch (e) { }
assert(ok, "orphaned bracket not considered parse error in regular expression literal");
try {
if (eval("/[]/.exec('')"))
ok = false;
} catch (e) {
ok = false;
}
assert(ok, "/[]/ either failed to parse or matched something");
var x = /(\3)(\1)(a)/.exec('cat'); // the \3 matches the empty string, qv. ES3:15.10.2.9
assert(x, "/(\\3)(\\1)(a)/ failed to match 'cat'");
assert(x.length == 4, "/(\\3)(\\1)(a)/ failed to return four components");
assert(x[0] == "a", "/(\\3)(\\1)(a)/ failed to find 'a' in 'cat'");
assert(x[1] == "", "/(\\3)(\\1)(a)/ failed to find '' in 'cat' as first part");
assert(x[2] == "", "/(\\3)(\\1)(a)/ failed to find '' in 'cat' as second part");
assert(x[3] == "a", "/(\\3)(\\1)(a)/ failed to find 'a' in 'cat' as third part");
try {
eval("/(1)(2)(3)\6(4)(5)/");
ok = false;
} catch (e) { }
assert(ok, "should have raised syntax error for a backreference to a non-existent capture");
try {
eval("/(1)\0(2)/");
ok = false;
} catch (e) { }
assert(ok, "should have raised syntax error for a backreference to the zeroth capture");
return 6;
},
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Eric Seidel (no email)
This is now called Test 90 and the test has changed so that we seem to PASS.
Would you like to keep this open Darin? If so we should remove the "(Acid3 bug)"
Darin Adler
Seems fine to keep it open.
Ian 'Hixie' Hickson
brendan seemed to suggest this would change in ES4. I recommend pushing for that since we have interop on this already anyway.
Darin Adler
OK, so we probably should not change the behavior.
Gavin Barraclough
Removing octal escapes would break the web, and ecmascript permits syntax extensions.