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

invalid escape sequence in regular expression #374

Open
technobuddha opened this issue Dec 13, 2024 · 5 comments
Open

invalid escape sequence in regular expression #374

technobuddha opened this issue Dec 13, 2024 · 5 comments

Comments

@technobuddha
Copy link

quickjs compilation is failing with the error message invalid escape sequence in regular expression on the following code:

const re = /[\-]/u;

However, if the 'u' flag is omitted it compiles fine.

I found this problem using the very popular npm library ajv-formats (26 million DL/week)

@bnoordhuis
Copy link
Contributor

I fixed that in 2023 in quickjs-ng/quickjs@f0ef9e1 although more as a side effect of a larger change. I think it should be possible to cherry-pick only the relevant bits though.

@benatkin
Copy link

benatkin commented Dec 29, 2024

It's more of a feature addition than a fix IMO

@technobuddha
Copy link
Author

It's more of a feature addition than a fix IMO

I don't see how this is a "feature". It's clearly a bug. Node, and most browsers accept the regex syntax. The syntax is part of the regexp documentation.

@benatkin
Copy link

benatkin commented Dec 31, 2024

I understand it better now and yeah it isn't a feature. It's a bug that only shows up when the code has an unnecessarily escaped - in a unicode string. The spec and docs are very clear that it doesn't need to be escaped, so that code ought to be fixed in ajv.

@technobuddha
Copy link
Author

@benatkin Exactly. I would consider this low-priority except for the fact that this is in several very popular npm packages including ajv.

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

No branches or pull requests

3 participants