Fixed unescape_strings bug introduced along \uNNNN unescaping.

This commit is contained in:
VittGam 2012-06-25 00:09:14 +02:00
parent eaba8d34a4
commit aac19da12c
3 changed files with 4 additions and 4 deletions

View File

@ -531,7 +531,7 @@ function js_beautify(js_source_text, options) {
//
while (esc || input.charAt(parser_pos) !== sep) {
resulting_string += input.charAt(parser_pos);
if (esc1 >= esc2) {
if (esc1 && esc1 >= esc2) {
esc1 = parseInt(resulting_string.substr(-esc2), 16);
if (esc1 && esc1 >= 0x20 && esc1 <= 0x7e) {
esc1 = String.fromCharCode(esc1);

View File

@ -629,11 +629,11 @@ class JSBeautifier
while ($esc || $this->input[$this->parser_pos] != $sep) {
$resulting_string .= $this->input[$this->parser_pos];
if ($esc1 >= $esc2) {
if ($esc1 && $esc1 >= $esc2) {
$esc1 = hexdec(substr($resulting_string, -$esc2));
if ($esc1 && $esc1 >= 0x20 && $esc1 <= 0x7e) {
$esc1 = chr($esc1);
$resulting_string = substr($resulting_string, 0, -($esc2 + 2)) . ((($esc1 === $sep) || ($esc1 === '\\')) ? '\\' : '') . $esc1;
$resulting_string = substr($resulting_string, 0, -2 - $esc2) . ((($esc1 === $sep) || ($esc1 === '\\')) ? '\\' : '') . $esc1;
}
$esc1 = 0;
}

View File

@ -557,7 +557,7 @@ class Beautifier:
# handle string
while esc or self.input[parser_pos] != sep:
resulting_string += self.input[parser_pos]
if esc1 >= esc2:
if esc1 and esc1 >= esc2:
try:
esc1 = int(resulting_string[-esc2:], 16)
except Exception: