Skip to content
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

entities 2.0.2 includes es6 regular expression flag/u #209

Closed
farmerx opened this issue May 14, 2020 · 14 comments · Fixed by manish-kothari/entities#1
Closed

entities 2.0.2 includes es6 regular expression flag/u #209

farmerx opened this issue May 14, 2020 · 14 comments · Fixed by manish-kothari/entities#1

Comments

@farmerx
Copy link

farmerx commented May 14, 2020

entities 2.0.2 includes es6 regular expression flag /u

@farmerx
Copy link
Author

farmerx commented May 14, 2020

const reNonASCII = /[^\0-\x7F]/gu;

@syabro
Copy link

syabro commented May 14, 2020

+1 here

It breaks IE. But since ts target is set to es5 maybe it's ts bug and it should be transformed somehow?

@mmaameriacap
Copy link

Same problem

@syabro
Copy link

syabro commented May 15, 2020

I think it could ve replaced new call.

const reNonASCII = new RegExp("[^\\0-\\x7F]", "gu"); 

@melnikaite
Copy link

No, in IE11 it still shows Syntax error in regular expression because of u modifier

@Nabsef
Copy link

Nabsef commented May 15, 2020

+1 here

It breaks IE. But since ts target is set to es5 maybe it's ts bug and it should be transformed somehow?

Same issue.

manish-kothari added a commit to manish-kothari/entities that referenced this issue May 16, 2020
Generated an equivalent regex using regexpu so that it does not break in IE.
This is to fix fb55#209
@venoral
Copy link

venoral commented May 18, 2020

hello, I have an old project, its node v4.4.2 npm v2.15.0, it use html-webpack-plugin v2.9.0, and html-webpack-plugin has a deep dependence to entities.
errors that
/tmp/build/src/node_modules/html-webpack-plugin/node_modules/pretty-error/node_modules/renderkid/node_modules/css-select/node_modules/domutils/node_modules/dom-serializer/node_modules/entities/lib/encode.js:54 var reNonASCII = /[^\0-\x7F]/gu; ^ SyntaxError: Invalid flags supplied to RegExp constructor 'gu' occurs when build.

This is because executes html-webpack-plugin’s code after
require('html-webpack-plugin');
now I could only downgrade html-webpack-plugin to v2.0.4, but I am reluctant to do so in order not to affect the other code of the project.
I look forward to your version of this issue or is there a better suggestion?
Thx!!!

@manish-kothari
Copy link
Contributor

manish-kothari commented May 18, 2020

I changed the regex to a version compatible with ES5 using regexpu:

const reNonASCII = /[^\0-\x7F]/gu;

to

const reNonASCII = /(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;

Perhaps this can help.
I have also raised pull request for this, hope this gets merged.

@Nabsef
Copy link

Nabsef commented May 18, 2020

Hello, I have just started npm insall for my package, I still have the old version "[email protected]" :

I think we have update or merge issue for the new version.

@melnikaite
Copy link

It's not yet merged to master, there are 2 PRs to fix this #212 and #208
As a workaround you can add to package.json version 2.0.0

@mmaameriacap
Copy link

mmaameriacap commented May 21, 2020

It's not yet merged to master, there are 2 PRs to fix this #212 and #208
As a workaround you can add to package.json version 2.0.0

Actually, in my side , I cannot use the version 2.0.0 because the problems is related to a dependency of dependency of dependency... So at the end , we don't have the control of the exact version to use. We cannot completely review the solution andI think it will be ridiculous to do it just regarding the change made in the entities. We are waiting the fix to be able to continue our development which are stopped since the change made.
The npm version using in our solution is very old and the option npm ci is not available yet...So thanks in advance for your work

@melnikaite
Copy link

You can try to install your own fork with working version using git url npm install mmaameriacap/entities
Probably npm will dedupe it and use for dependencies of dependencies

@JonShort
Copy link

Hi all - a workaround for others which are having issues with this being a sub-dependency is to manually edit your lockfile, replacing any entities 2.0.2 with 2.0.0:

Then just make sure your CI is using npm ci or yarn install --frozen-lockfile respectively.

npm:

"entities": {
    "version": "2.0.0",
    "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.0.tgz",
    "integrity": "sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw=="
}

yarn:

[email protected]:
  version "2.0.0"
  resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.0.tgz#68d6084cab1b079767540d80e56a39b423e4abf4"
  integrity sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw==

@shobhitchittora
Copy link

Hi all!
When can we release a patch version with the backward compat fixes? Any updates on this?

@fb55 fb55 closed this as completed in 77fc4a9 Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants