Bug 430927 - Don't decompile to \0 as it was incorrectly interpreted as octal. r=waldo

This commit is contained in:
Tom Schuster 2011-11-03 21:58:06 +01:00
parent aa3bb9941f
commit 43c95644be
3 changed files with 16 additions and 2 deletions

View File

@ -804,7 +804,6 @@ const char js_EscapeMap[] = {
'"', '"',
'\'', '\'',
'\\', '\\',
'\0', '0'
};
#define DONT_ESCAPE 0x10000
@ -852,7 +851,7 @@ QuoteString(Sprinter *sp, JSString *str, uint32 quote)
/* Use js_EscapeMap, \u, or \x only if necessary. */
bool ok;
const char *e;
if (!(c >> 8) && (e = strchr(js_EscapeMap, (int)c)) != NULL) {
if (!(c >> 8) && c != 0 && (e = strchr(js_EscapeMap, (int)c)) != NULL) {
ok = dontEscape
? Sprint(sp, "%c", (char)c) >= 0
: Sprint(sp, "\\%c", e[1]) >= 0;

View File

@ -61,3 +61,4 @@ script regress-677924.js
skip-if(!xulRuntime.shell) script regress-696109.js
script regress-691746.js
script regress-697515.js
script toSource-0.js

View File

@ -0,0 +1,14 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
assertEq(eval(uneval('\x001')), '\x001');
f = eval('(' + (function () { return '\x001'; }).toString() + ')');
assertEq(f(), '\x001');
assertEq(eval('\x001'.toSource()) == '\x001', true);
if (typeof reportCompare === 'function')
reportCompare(true, true);