Skip to content

Backslashes missing on output code #232

@almosnow

Description

@almosnow

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions