Bug 16514 - RegExp properties should not depend on RegExp.input
Summary: RegExp properties should not depend on RegExp.input
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 523.x (Safari 3)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2007-12-19 04:26 PST by Kevin Millikin
Modified: 2011-09-06 22:30 PDT (History)
2 users (show)

See Also:


Attachments
Test case (282 bytes, text/html)
2007-12-19 05:49 PST, David Kilzer (:ddkilzer)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Millikin 2007-12-19 04:26:10 PST
Changing RegExp.input should not change RegExp.lastMatch, RegExp.$1, etc.  In Safari 523.13:

'This seems like the right behavior'.match(/right/);
RegExp.lastMatch; // == 'right'
RegExp.input = 'Whereas this one is wrong, yo';
RegExp.lastMatch; // == 'wrong'
Comment 1 David Kilzer (:ddkilzer) 2007-12-19 05:49:21 PST
Created attachment 17989 [details]
Test case

MSIE 7 and Firefox 2.0.0.11 report "right" in both cases (as expected).

Opera 9.24 reports "undefined" in both cases (apparently doesn't support these properties on their RegExp object).

A local debug build of WebKit r28828 with Safari 3.0.4 (523.12) on Mac OS X 10.4.11 (8S165) reports "right" and "wrong".
Comment 2 David Kilzer (:ddkilzer) 2007-12-19 05:51:51 PST
Not a regression from Safari 2.0.4 as it reports "undefined" for both values.

Comment 3 Kevin Millikin 2007-12-19 06:09:42 PST
Thanks for looking into this.

It looks like all the deprecated properties of the RegExp constructor (lastMatch, leftContext, rightContext, lastParen, and $1 through $9) are computed lazily based on RegExp.input.  However, RegExp.input is not necessarily the last matching subject string.
Comment 4 Gavin Barraclough 2011-09-06 22:30:36 PDT
Looks like this is a very old bug; this works fine in ToT.