WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
79938
'source' property of RegExp instance cannot be ""
https://bugs.webkit.org/show_bug.cgi?id=79938
Summary
'source' property of RegExp instance cannot be ""
Gavin Barraclough
Reported
2012-02-29 13:25:43 PST
15.10.6.4 specifies that RegExp.prototype.toString must return '/' + source + '/', and also states that the result must be a valid RegularExpressionLiteral. '//' is not a valid RegularExpressionLiteral (since it is a single line comment), and hence source cannot ever validly be "". If the source is empty, return a different Pattern that would match the same thing.
Attachments
Fix
(11.73 KB, patch)
2012-02-29 13:32 PST
,
Gavin Barraclough
oliver
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Gavin Barraclough
Comment 1
2012-02-29 13:32:28 PST
Created
attachment 129505
[details]
Fix
Gavin Barraclough
Comment 2
2012-02-29 15:24:49 PST
Fixed in
r109275
Erik Arvidsson
Comment 3
2012-02-29 16:21:03 PST
We should update the spec for this. We should point out that the "source" property cannot be "" due to the toString behavior.
Gavin Barraclough
Comment 4
2012-02-29 17:03:50 PST
(In reply to
comment #3
)
> We should update the spec for this. We should point out that the "source" property cannot be "" due to the toString behavior.
Aye, that sounds like a good plan – I got half way through filing a bug against test262 before realizing this. :-)
Kentaro Hara
Comment 5
2012-02-29 17:38:55 PST
Your patch fixed JSC only, and RegExp.html starts to fail on Chromium/V8. - Since this requires a fix in V8, I filed a bug in V8:
http://code.google.com/p/v8/issues/detail?id=1983&thanks=1983&ts=1330565749
- I'll add the FAIL line to chromium/test_expectations.txt
Erik Arvidsson
Comment 6
2012-02-29 21:34:21 PST
I thought Adam already took care of adding this to the test_expectations?
Kentaro Hara
Comment 7
2012-02-29 21:35:36 PST
(In reply to
comment #6
)
> I thought Adam already took care of adding this to the test_expectations?
Yeah, I found the line:) I just filed a bug in V8. Thanks.
Kentaro Hara
Comment 8
2012-02-29 21:36:20 PST
(In reply to
comment #7
)
> (In reply to
comment #6
) > > I thought Adam already took care of adding this to the test_expectations?
Ah, the V8 bug is already there. Sorry for the confusion.
Erik Corry
Comment 9
2012-03-01 00:57:02 PST
How about: re = new RegExp("\n"); eval(re.toString()); // Syntax error.
Andreas Rossberg
Comment 10
2012-03-01 01:56:19 PST
Note that the spec of toString uses the 'source' property of the regexp object, which Section 15.10.4.1 specifies to be the properly escaped version of the original argument string. The same paragraph in that section also specifies explicitly that 'source' should be set to "(?:)" if the original string is empty.
Gavin Barraclough
Comment 11
2012-03-01 15:52:46 PST
(In reply to
comment #10
)
> Note that the spec of toString uses the 'source' property of the regexp object, which Section 15.10.4.1 specifies to be the properly escaped version of the original argument string. The same paragraph in that section also specifies explicitly that 'source' should be set to "(?:)" if the original string is empty.
Ah, I had somehow managed to overlook that, thank you! I guess I can simplify my comment, and just reference this rather than deriving the behavior. :-)
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug