mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-23 04:40:06 +00:00
Fixed unescape_strings bug introduced along \uNNNN unescaping.
This commit is contained in:
parent
eaba8d34a4
commit
aac19da12c
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user