Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed unescape_strings bug introduced along \uNNNN unescaping.
  • Loading branch information
VittGam committed Jun 24, 2012
1 parent eaba8d3 commit aac19da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion beautify.js
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions php/jsbeautifier.php
Expand Up @@ -629,11 +629,11 @@ private function get_next_token()
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;
}
Expand Down
2 changes: 1 addition & 1 deletion python/jsbeautifier/__init__.py
Expand Up @@ -557,7 +557,7 @@ def get_next_token(self):
# 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:
Expand Down

1 comment on commit aac19da

@alkavan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! I just stumbled in this issue. with /u000 char.

Please sign in to comment.