Bug 103822
Summary: | RegExp.prototype.exec should always update lastIndex if no match was found | ||
---|---|---|---|
Product: | WebKit | Reporter: | André Bargull <andre.bargull> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | UNCONFIRMED | ||
Severity: | Normal | CC: | barraclough, claude.pache, msaboff, ngockhanhlam87 |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All |
André Bargull
Steps to reproduce:
Simple test case:
---
js> r = /a/; r.lastIndex = 1; r.exec("zzzz"); r.lastIndex
1
---
Actual results:
`r.lastIndex` should have been set to `0` per ES5.1, cf. [15.10.6.2 RegExp.prototype.exec(string) - step 9a].
Spidermonkey and V8 also return `1` whereas IE10 and Opera12 return `0`.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
André Bargull
RegExp.prototype.test, String.prototype.match and String.prototype.replace are also affected.
List of different javascript engines/browsers and the result for each test:
---
r = /a/; r.lastIndex = 1; r.exec("zzzz"); r.lastIndex
Bad: JSC, V8, SM
Good: Opera, IE
r = /a/; r.lastIndex = 1; r.test("zzzz"); r.lastIndex
Bad: JSC, V8, SM, Opera
Good: IE
r = /a/; r.lastIndex = 1; "zzzz".match(r); r.lastIndex
Bad: JSC, V8, SM
Good: Opera, IE
r = /a/; r.lastIndex = 1; "zzzz".replace(r, ""); r.lastIndex
Bad: JSC, V8, SM, Opera
Good: IE
---