Unicode non-character treated as whitespace

NEW
Unassigned

Status

()

Core
JavaScript Engine
P3
normal
7 months ago
3 months ago

People

(Reporter: gazheyes, Unassigned)

Tracking

({triage-deferred})

53 Branch
triage-deferred
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [parity-webkit])

(Reporter)

Description

7 months ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0
Build ID: 20170504105526

Steps to reproduce:

eval("alert"+String.fromCharCode(65534)+"(1)");


Actual results:

alert function is called character 65534 is treated as whitespace


Expected results:

Illegal character exception should be thrown since character 65534 is not a valid whitespace character. It is not listed on:
https://tc39.github.io/ecma262/#sec-white-space
Google Chrome Canary also treats it as whitespace, and WebKit throws syntax error.

[Google Chrome Canary]
> eval("alert"+String.fromCharCode(65534)+"(1)");
< undefined

[WebKit]
> eval("alert"+String.fromCharCode(65534)+"(1)");
< SyntaxError: Invalid character '\u65534'

(btw, the error message is wrong...)
Status: UNCONFIRMED → NEW
Component: Untriaged → JavaScript Engine
Ever confirmed: true
Product: Firefox → Core
Whiteboard: parity-webkit]

Updated

7 months ago
Whiteboard: parity-webkit] → [parity-webkit]
es6draft also throws SyntaxError

js> eval("print"+String.fromCharCode(65534)+"(1)");
uncaught exception: SyntaxError: missing semi-colon after statement
(Reporter)

Comment 3

7 months ago
I've reported it to Chrome too.
We seem to accept U+FFFE for compatibility reasons:
http://searchfox.org/mozilla-central/rev/a14524a72de6f4ff738a5e784970f0730cea03d8/js/src/vm/Unicode.h#245-247
maybe, it's a spec bug for web compatibility?
Keywords: triage-deferred
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.