WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
138129
String.prototype.split gives incorrect result in some cases: "a".split(/$/) == ["a",""] not ["a"].
https://bugs.webkit.org/show_bug.cgi?id=138129
Summary
String.prototype.split gives incorrect result in some cases: "a".split(/$/) =...
Lasse Reichstein Holst Nielsen
Reported
2014-10-28 02:44:21 PDT
String.prototype.split gives an incorrect result in some cases. When doing "a".split(/$/), the result is ["a", ""]. The result should be ["a"]. This was seen in Safari 7.1. From the es5 spec: "The value of separator may be an empty String, an empty regular expression, or a regular expression that can match an empty String. In this case, separator does not match the empty substring at the beginning or end of the input String, nor does it match the empty substring at the end of the previous separator match." In this case, the regexp can only match an empty substring at the end of the input, and by the above text, that match is ignored wrt. splitting, so the result should be the same as with no match, ["a"].
Attachments
Updated split such that it does not include the empty end of line string.
(3.63 KB, patch)
2015-01-21 14:27 PST
,
Matthew Mirman
mmirman
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2014-10-28 23:04:43 PDT
<
rdar://problem/18807403
>
Matthew Mirman
Comment 2
2015-01-21 14:27:32 PST
Created
attachment 245088
[details]
Updated split such that it does not include the empty end of line string.
Matthew Mirman
Comment 3
2015-01-21 14:43:52 PST
Patch landed:
http://trac.webkit.org/changeset/178860
Closing bug.
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