Closed Bug 368694 Opened 18 years ago Closed 13 years ago

toString of javascript functions contains escaped characters

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 621814

People

(Reporter: sjoerd, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
Build Identifier: 

(function ç(ç){var ç})+""
gives
function \xE7(\xE7) { var \xE7; }
literally, i.e. \xE7 is 4 characters:

>>> ((function ç(ç){var ç})+"").length
37
>>> ((function a(a){var a})+"").length
28

Reproducible: Always
Confirmed using http://www.squarefree.com/shell/shell.html on Mac trunk.  Note that the original function compiles while the toString result does not.

> (function å() { })
function \xE5() { }

> function \xE5() { }
SyntaxError on line 1: illegal character

> (function å() { }).name
å
Status: UNCONFIRMED → NEW
Ever confirmed: true
Still happens in FF 7
Not sure, but this is working for me and should actually be in Firefox 7.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Simple test here shows that it is still escaping characters:
http://jsbin.com/osuloq and screenshot http://cl.ly/0g3s150n403j3n3b2o0l
This bug was about hex escape which is not valid in that context, and thus threw an error. We currently escape everything except some printable characters in ASCII range. To really fix that we would need to implement checking if a character in the Unicode range is printable. This would better be handled in some other bug.
You need to log in before you can comment on or make changes to this bug.