RegExp.escape()

Mark S. Miller erights at google.com
Sat Jun 27 16:17:48 UTC 2015


Safety over readability please. If there is a single fully escaped form
that is safe to use in all the expected contexts, let's choose that. The
results of RegExp.escape are not very readable anyway, and rarely read. So
compromising safety for some contexts in exchange for incremental
readability improvements of something that won't be read is not a good idea.

If there is not a clearly most escaped form that is safe in all expected
contexts, then first, let us enumerate all the relevant contexts and the
escaping demands of each.



On Sat, Jun 27, 2015 at 8:37 AM, Benjamin Gruenbaum <benjamingr at gmail.com>
wrote:

> I'd like to give https://github.com/benjamingr/RegExp.escape/issues/29
> another week *please, if you have a strong opinion voice it* after which
> we'll settle on a hopefully *final* API for RegExp.escape in terms of the
> escaped parts.
>
> Some parts so you won't have to read the whole thread (debated issues):
>
>  - Numeric literals are escaped at the start of the string to not
> interfere with capturing groups (yes/no)
>  - Hex characters ([0-9a-f]) are escaped at the start of the string to not
> interfere with unicode escape sequences (yes/no)
>  - `/` is escaped to support passing a RegExp string to eval (yes/no)?
>
> And so on.
>
> On Sat, Jun 20, 2015 at 2:07 PM, Benjamin Gruenbaum <benjamingr at gmail.com>
> wrote:
>
>> As a cross-cutting concern I'd like the feedback of more people on
>> https://github.com/benjamingr/RegExp.escape/issues/29
>>
>> Basically we've got to make a design choice of readable output vs.
>> potentially safer output.
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150627/66a4546b/attachment.html>


More information about the es-discuss mailing list