-
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
Unicode escaping in regex is incorrectly minified. #2569
Comments
That library is probably using some illegal unpaired surrogate. See: #2242 This works:
|
Reduced test case:
Unpaired surrogates must be output in ascii in the default binary output mode. |
If so, I guess it's just a matter of backporting part of that logic onto |
#2242 has the background of master and harmony diverging - and how node streams cannot handle unpaired binary surrogates. The reduced test case above was done with harmony. Other ES parsers keep and use the raw string. Uglify does not. We probably have to step through the string char by char to output it properly in binary mode. |
@kzc Awesome. Thanks so much for helping produce the reduced test case. @alexlamsl Thanks for the fast response / tagging. |
Even though it can probably be accommodated by uglify, I still have my doubts that the original string with unpaired surrogates - even in ascii form - is valid ECMAScript. The ES spec is silent on the use of unpaired surrogates in both strings and RegExp. It's probably a defacto browser thing. Even node converts such a regex to a string by replacing the lone surrogates with the Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD):
Related unicode regular expression spec:
and related discussion:
|
Those affected can use the |
The fix will be in v3.2.3. |
Awesome!! Thank you guys. |
I am at uglify 3.3.1 and it still screw my regexes breaking the prod builds |
minifiying commonmark.js when building via the most recent react-create-app yields this error: I've installed v3.3.9 of uglify-js |
Bug report
ES5
Uglify version (
uglifyjs -V
)uglify-js 3.2.1
JavaScript input
Source of this line of code is from the emojione library (emojione.js#L160).
The
uglifyjs
CLI command executed orminify()
options used.uglifyjs --compress --beautify beautify=false,semicolons=false --mangle -- emojione.js
JavaScript output or error produced.
The above snippet is unparsable.
Some version bi-secting shows that this last worked correctly in v3.0.25 and was first broken in v3.1.0. I took a look at the compare for thos two versions, but I just don't posses the required skillset to debug this stuff. I wish I could be more help.
The text was updated successfully, but these errors were encountered: