If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

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

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
5 years ago
5 years ago

People

(Reporter: Kyle Falconer, Unassigned)

Tracking

17 Branch
x86_64
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
Created attachment 694516 [details]
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
Last Resolved: 5 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.