Permalink
Browse files

Fixed unescape_strings bug introduced along \uNNNN unescaping.

  • Loading branch information...
1 parent eaba8d3 commit aac19da12ce409d6c1fe89de4441efcf5e72a841 @VittGam VittGam committed Jun 24, 2012
Showing with 4 additions and 4 deletions.
  1. +1 −1 beautify.js
  2. +2 −2 php/jsbeautifier.php
  3. +1 −1 python/jsbeautifier/__init__.py
View
@@ -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
@@ -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;
}
@@ -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:

1 comment on commit aac19da

Contributor

alkavan commented on aac19da Jun 25, 2012

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

Please sign in to comment.