mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-30 08:00:55 +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) {
|
while (esc || input.charAt(parser_pos) !== sep) {
|
||||||
resulting_string += input.charAt(parser_pos);
|
resulting_string += input.charAt(parser_pos);
|
||||||
if (esc1 >= esc2) {
|
if (esc1 && esc1 >= esc2) {
|
||||||
esc1 = parseInt(resulting_string.substr(-esc2), 16);
|
esc1 = parseInt(resulting_string.substr(-esc2), 16);
|
||||||
if (esc1 && esc1 >= 0x20 && esc1 <= 0x7e) {
|
if (esc1 && esc1 >= 0x20 && esc1 <= 0x7e) {
|
||||||
esc1 = String.fromCharCode(esc1);
|
esc1 = String.fromCharCode(esc1);
|
||||||
|
@ -629,11 +629,11 @@ class JSBeautifier
|
|||||||
while ($esc || $this->input[$this->parser_pos] != $sep) {
|
while ($esc || $this->input[$this->parser_pos] != $sep) {
|
||||||
$resulting_string .= $this->input[$this->parser_pos];
|
$resulting_string .= $this->input[$this->parser_pos];
|
||||||
|
|
||||||
if ($esc1 >= $esc2) {
|
if ($esc1 && $esc1 >= $esc2) {
|
||||||
$esc1 = hexdec(substr($resulting_string, -$esc2));
|
$esc1 = hexdec(substr($resulting_string, -$esc2));
|
||||||
if ($esc1 && $esc1 >= 0x20 && $esc1 <= 0x7e) {
|
if ($esc1 && $esc1 >= 0x20 && $esc1 <= 0x7e) {
|
||||||
$esc1 = chr($esc1);
|
$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;
|
$esc1 = 0;
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ class Beautifier:
|
|||||||
# handle string
|
# handle string
|
||||||
while esc or self.input[parser_pos] != sep:
|
while esc or self.input[parser_pos] != sep:
|
||||||
resulting_string += self.input[parser_pos]
|
resulting_string += self.input[parser_pos]
|
||||||
if esc1 >= esc2:
|
if esc1 and esc1 >= esc2:
|
||||||
try:
|
try:
|
||||||
esc1 = int(resulting_string[-esc2:], 16)
|
esc1 = int(resulting_string[-esc2:], 16)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
Reference in New Issue
Block a user