Bug 130184 - String.prototype.trim removes U+200B from strings.
Summary: String.prototype.trim removes U+200B from strings.
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 525.x (Safari 3.2)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Geoffrey Garen
Depends on:
Reported: 2014-03-13 02:58 PDT by Lasse R.H. Nielsen
Modified: 2014-04-29 12:47 PDT (History)
4 users (show)

See Also:

Patch (4.55 KB, patch)
2014-04-29 12:42 PDT, Geoffrey Garen
msaboff: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lasse R.H. Nielsen 2014-03-13 02:58:48 PDT
In the current version of Safari on a Mac, the String.prototype.trim function removes "\u200b" characters from the string. That character is not recognized as whitespace by the ECMAScript 5 spec (or the ES6 drafts), and should not be removed.

Example code:  alert("\u200b".trim().length);  // should alert 1, actually alerts 0.

Apologies if this has been fixed in a nightly build.
Comment 1 Alexey Proskuryakov 2014-04-29 12:17:12 PDT
Adding this character was intentional, see discussion in bug 26590. Seems like maybe we should remove it now to match the new standard.
Comment 2 Geoffrey Garen 2014-04-29 12:30:40 PDT
Looks like bug 26590 was written to match a draft specification, but no ratified specification ever included u200b, Unicode does not include u200b in the 'Separator, Space' category, and Firefox does not include it either.
Comment 3 Geoffrey Garen 2014-04-29 12:42:02 PDT
Created attachment 230402 [details]
Comment 4 Michael Saboff 2014-04-29 12:46:12 PDT
Comment on attachment 230402 [details]

Comment 5 Geoffrey Garen 2014-04-29 12:47:49 PDT
Committed r167951: <http://trac.webkit.org/changeset/167951>