-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backslashes missing on output code #232
Comments
This is expected, because |
Yeah, well, I don't think those should get escaped. Check this out:
As you will see A != C but B == D, and that is wrong. Sure both strings are actually 'equivalent' (and I can imagine this as one of the reasons why this could've been purposedly coded as a feature), but they are not the same; and you can see in my first example that this situation leads to code that breaks. |
After this line, your variable '\" NO WAY, JOSE \"' Now you're asking UglifyJS to parse that as code. Copy/paste the above line in a file if you want and run UglifyJS on it, and you'll get the correct result: '" NO WAY, JOSE "' Because this thing starts with a quote ( |
|
@rvanvelzen great minds think alike. ;-) |
K, got it now, thanks both. |
This is still an issue for Regex strings.
|
That is not an issue - |
That's not true.
See: https://regex101.com/r/vejuUa/1 and https://regex101.com/r/vejuUa/2 |
We're talking about strings now, not regexes. Just execute the snippet in your console and you'll realize. |
|
Sorry @kzc that's a typo on my part. I did mean RegExp, not Regex. |
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:
Output:
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.
The text was updated successfully, but these errors were encountered: