Incorrect decompilation with non-ASCII property name in destructuring (621814, r=igor).

This commit is contained in:
Brendan Eich 2010-12-28 18:43:38 -08:00
parent 97408da376
commit 2b4b0e0cd7
3 changed files with 20 additions and 1 deletions

View File

@ -756,7 +756,12 @@ QuoteString(Sprinter *sp, JSString *str, uint32 quote)
? Sprint(sp, "%c", (char)c) >= 0
: Sprint(sp, "\\%c", e[1]) >= 0;
} else {
ok = Sprint(sp, (c >> 8) ? "\\u%04X" : "\\x%02X", c) >= 0;
/*
* Use \x only if the high byte is 0 and we're in a quoted string,
* because ECMA-262 allows only \u, not \x, in Unicode identifiers
* (see bug 621814).
*/
ok = Sprint(sp, (qc && !(c >> 8)) ? "\\x%02X" : "\\u%04X", c) >= 0;
}
if (!ok)
return NULL;

View File

@ -64,3 +64,4 @@ script regress-619003-1.js
script regress-619003-2.js
script regress-620376-1.js
script regress-620376-2.js
script regress-621814.js

View File

@ -0,0 +1,13 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
var expect = 'pass';
var actual = expect;
function f({"\xF51F": x}) {}
try {
eval(uneval(f));
} catch (e) {
actual = '' + e;
}
reportCompare(expect, actual, "");