-
Notifications
You must be signed in to change notification settings - Fork 34
Escape (whitespace) control characters #30
Comments
I'm in favour if you can find me one example in real code where this would help someone |
This seems automatically bad given the desire for
|
Wait, no, it turns out |
Hmm, ok I've given this some thought now, this is something that needs to be solved from the Moreover, this is a bug, according to the spec for EscapeRegExpPattern:
So to sum it up:
Thanks for the issue! Keep em' coming! |
Ah, that's right, However, I think there's nothing wrong with doing this on both sides.
Well, you've found it yourself - the V8 implementation of I do agree that we hardly expect control characters being passed to |
This is a bug in V8 though (other browsers work correctly). I'm not sure why we would want to specify a workaround for a current (and interim) bug in V8. |
I mean that this kind of bug might happen in user code as well, in cases where Indeed, the question boils down to How much safety do want in |
eval
(and many other functions based on common assumptions)Specifically, I'm looking at linebreaks:
I'd love
RegExp.escape("\n")
to yield"\\n"
, not the linebreak"\n"
. Same for all other control characters code units like\r
and\t
. The algorithm might be based on JSON string escaping, though not using the short form for backspace (\b
).The text was updated successfully, but these errors were encountered: