-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
I'm using uglify-js inside a node program. I've noticed that sometimes the code returned from an AST is not what I would expect. I don't know if this is a bug or the intended behavior.
How to reproduce:
Execute the following node program:
var uglify = require('uglify-js');
var js = JSON.stringify(['var a = "OK";']);
console.log('A:' + js);
var code = "JSON.parse('" + js + "');";
console.log('B:' + code);
code = uglify.parse(code).print_to_string();
console.log('C: ' + code);
Output:
A: ["var a = \"OK\";"]
B: JSON.parse('["var a = \"OK\";"]');
C: JSON.parse('["var a = "OK";"]');
As you can see, the backslashes are missing on C, this removes the 'escaping' of the quotes surrounding OK and creates an error later if one would try to evaluate the JSON.parse code.
Also, it behaves the same way when explicitly using an OutputStream object.
I'm using uglify-js v2.3.6 and node v0.10.12.
Metadata
Metadata
Assignees
Labels
No labels