Closed Bug 823657 Opened 12 years ago Closed 12 years ago

zero-width space is parsed as an illegal character in JavaScript

Categories

(Core :: JavaScript Engine, defect)

17 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: kfalconer, Unassigned)

Details

Attachments

(1 file)

Attached file zwsp.html
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11

Steps to reproduce:

I pasted a section of code from jsFiddle, which included a function closed with a '}' character, followed immediately by a zero-width space character, into a JavaScript file I am developing. After saving the JavaScript file, I refreshed my test page in Firefox (by pressing Ctrl-r) I am working on which attempts to load the script.

More generally, any page which attempts to load a script with a ZWSP character following a '}' character will present this error. Attached is an example which produces the error (note the ZWSP following the '}' closing function "test")


Actual results:

The developer console reports an error (below) and the script fails to load.

SyntaxError: illegal character
[Break On This Error] 	

}​;

zwsp.html (line 8, col 1)



Expected results:

The ZWSP character should be effectively ignored and the script parsed as if the ZWSP character were just a normal space. The wikipedia article on the ZWSP character (http://en.wikipedia.org/wiki/Zero-width_space) indicates that this character is used for indicating word boundaries, and should be treated as such.
Attachment #694516 - Attachment mime type: text/plain → text/html
Assignee: nobody → general
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
U+200B ZERO WIDTH SPACE is not a white space in ECMA-262.
http://ecma-international.org/ecma-262/5.1/#sec-7.2
(The general category of U+200B is Cf, not Zs.)
http://www.unicode.org/Public/UNIDATA/UnicodeData.txt

Chrome and IE10 also throw SyntaxError.
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: