-
Notifications
You must be signed in to change notification settings - Fork 32
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
Does / need to be escaped? #12
Comments
Can you think of example code that does not involve As far as I'm aware (please correct me if I'm wrong) this is not a problem if instead you did:
|
We can't ignore the existence of
Finally, note that use of In fact, looking at this suggests to me, that there may be additional work that is needed to ensure that EscapeRegExpPattern and |
|
I have looked at If you have any idea how to unify them or work on them together I'd love to hear it. Do you think I should open a separate issue for this? |
BTW |
@zloirock thanks, I wrote the polyfill and then changed my mind about this at one point. I'll update either the spec or polyfill.js as soon as we reach agreement about this. |
I think it is necessary at first not for |
Do you have a convincing use case for me illustrating it? By the way - different languages with On Sun, Jun 14, 2015 at 10:36 AM, Denis Pushkarev notifications@github.com
|
I once had a ugly necessity to generate regular expressions on serverside (node) and send it to client as code :) Or, for example, writing plugins for Babel / macros for Sweet.js / something else. |
@allenwb re-reading my previous comments I don't think they're convincing. I'll see how much real data I can dig around and come back in a day or two with actual data rather than my own private speculation about what people actually do and don't do. Any help from your experience about how to go on about this sort of research would be appreciated - right now I'm going through GitHub and looking for how people are using eval with strings that contain |
@allenwb so far I'm fairly optimistic about not including |
You might want to approach this from a purely cost effectiveness standpoint: If there exist such things out in the wild, no matter their diversity or significance, then you know the premise of @allenwb's suggestion stands. Isn't your time better spent doing other things than researching just how much this construct is used? |
No, deciding on the escaped character set is a big deal in my opinion and I take not breaking existing code and staying compatible very seriously but On Sun, Jun 14, 2015 at 9:32 PM, Zirak notifications@github.com wrote:
|
@allenwb I've not found significant evidence of this pattern on GH, 10000 biggest websites according to the alexa list or npm. The usages are sporadic and rare on the web. I'm closing this and removing |
@benjamingr I think this is a topic that should be presented to TC39 as an issue during the review of your initial proposal . I'm particularly concerned that with your proposal we would now have to different forms of regexp escaping in the spec: that performed by RegExp.escape and that performed by RegExp.protoype.toString/EscapeRegExpPattern. This sort of almost, but not quite, duplicate behavior is a "code smell" for language feature design. Note that one fix may be to change EscapeRegExpPattern since its current spec. doesn't require string identical results across implementations. Regardless, this is the sort of issue that TC39 likes to hash out and rtry to reach a consensus about. |
@allenwb definitely agreed. EscapeRegExpPattern looks very under specified. Note that unless we end up escaping all alphanumeric characters (as per the alternative here #15 ) they are pretty close - and I think we might be able to get EscapeRegExpPattern to reuse the logic specified here (which would also mean it would be guaranteed to produce the same results in all engines) |
@allenwb we now have more data points about EscapeRegExpPattern https://github.com/benjamingr/RegExp.escape/blob/master/data/EscapeRegExpPattern.md , we're currently looking at what engines do about it (In Firefox, it/s very literal for example). @EladRK is collecting this data and is working on it, we'll have final data soon. Any comments would be very appreciate. |
Superseding this with #29 |
/ is not a character matched by the RegExp grammar SyntaxCharacter production. However, it seems like it might be a character that should be escaped. Particularly, if a string is being converted to a RegExp literal:
The text was updated successfully, but these errors were encountered: