-
Notifications
You must be signed in to change notification settings - Fork 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
Escape literal [ in regexp #3885
Escape literal [ in regexp #3885
Conversation
Improves compatibility with strict ES5 regexp syntax
Huh. I thought that
"escaping" these won't have any adverse consequences? |
"SourceCharacter but not one of \ or ] or -" from http://www.ecma-international.org/ecma-262/5.1/#sec-15.10.1 the regular expression grammar seems to exclude it. Most other language's require it to be escaped too.
Seems to still match any literal (/[\[]/).test("one two [ three")
// true |
@josh: That allows |
@michaelficarra GitHub garbled that. It actually disallows |
No, I don't think it does. I looked at the production in the spec. |
Ah, you're right. I was confused by the "PatternCharacter" bit. This is actually the relevant rule:
I'll revert. |
Sorry, my mistake. The character class stuff actually seems fine, L840 doesn't need to be changed. The parse error is actually on the closing Thats a literal Would you guys reconsider just changing L844? or am I still wrong about the grammar 😉 |
That sounds right. Please open a new PR. |
See #3893. |
Regexps parsing regexps always causing trouble.
It'd be nice if we could escape the literal
[
in within the character class here to improve compatibility with "stricter ES5 regexp engines".For context, I'm trying to get the CoffeeScript parser running under the Duktape interpreter. It has a stricter regexp parser svaarala/duktape#86 svaarala/duktape#74
/cc @sstephenson @jashkenas