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 character escape returns error in regress but is accepted in other JS engines #26

Open
jasonwilliams opened this issue Jan 2, 2021 · 4 comments

Comments

@jasonwilliams
Copy link

jasonwilliams commented Jan 2, 2021

In Boa we had an issue of

const a = /,\;/`

causing a panic, due to regress triggering a "Invalid character escape" panic.
However this seems to be acceptable in other JS engines, running the above in chrome for example is allowed.

Is there somewhere in the specification that does not allow invalid escapes?
Linked to Boa PR: boa-dev/boa#1027

@jasonwilliams jasonwilliams changed the title Invalid character escape panics in regress but is accepted in other JS engines Invalid character escape returns error in regress but is accepted in other JS engines Jan 2, 2021
@ridiculousfish
Copy link
Owner

Apologies for the delay. regress assumes the JS Unicode flag 'u' is set, which does not allow this escape:

> const a = /,\;/u
Uncaught SyntaxError: Invalid regular expression: /,\;/: Invalid escape

How would you like to proceed? If we need to tweak the syntax, or add a new flag I can do that.

@AnnikaCodes
Copy link

AnnikaCodes commented Jan 7, 2021

Probably we should disable the Unicode support unless the /u flag is set. Is that possible to do within Regress?

@ridiculousfish
Copy link
Owner

There's no support for non-Unicode in regress today. Non-Unicode regexes per the JS spec have a lot of terrible semantics: only supports BMP, its case folding is crazy.

But probably regress can have a mode that supports the non-Unicode syntax (including this escape) but still supports the Unicode semantics. I can work on adding that.

@jasonwilliams
Copy link
Author

Sounds good @ridiculousfish 👍

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