lautis/uglifier — Issue #24: Error compiling Unicode escape sequence
Author: r-stu31
Created: 2012-01-05 20:10:19+00:00
State: open

uglifier-1.2.1 can't compile the following JavaScript code:

```js
var str = "\u201E";
```

My environment:
ruby_1_9_3-r34209
multi_json-1.0.4
execjs-1.2.13
uglifier-1.2.1

The complete session log (paths in backtrace trimmed):
```
$ cat pr1.js
var str = "\u201E";
$ irb
irb(main):001:0> require 'uglifier'
=> true
irb(main):002:0> Uglifier.new.compile(File.read("pr1.js"))
MultiJson::DecodeError: 387: unexpected token at '"var str=\"\""]
'
from /opt/ruby_1_9_3-r34209/lib/ruby/1.9.1/json/common.rb:148:in `parse'
from /opt/ruby_1_9_3-r34209/lib/ruby/1.9.1/json/common.rb:148:in `parse'
from /[...]/gems/multi_json-1.0.4/lib/multi_json/engines/json_common.rb:9:in `decode'
from /[...]/gems/multi_json-1.0.4/lib/multi_json.rb:76:in `decode'
from /[...]/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:61:in `extract_result'
from /[...]/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:27:in `block in exec'
from /[...]/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
from /[...]/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:26:in `exec'
from /[...]/gems/uglifier-1.2.1/lib/uglifier.rb:101:in `compile'
from (irb):2
from /opt/ruby_1_9_3-r34209/bin/irb:12:in `

'
irb(main):003:0>
```

The problematic Unicode character is a "low double comma quotation mark" (http://www.unicode.org/charts/PDF/U2000.pdf). I stumbled upon this by uglifiing a tiny_mce.js from https://github.com/spohlenz/tinymce-rails/blob/master/assets/vendor/tinymce/tiny_mce.js#L1238 (TinyMCE 3.4.7) - see code block starting at line 1238, "asciiMap" variable).