crash when using an invalid regular expression

50 views
Skip to first unread message

Do Bi

unread,
Feb 3, 2015, 6:58:00 AM2/3/15
to elm-d...@googlegroups.com
Hi,

I want to allow my users to input a regular expression.
Right now my webapp crashes when they enter something invalid, e.g. "\".
screenshot: http://i.imgur.com/2vLkarN.png
code: http://codepad.org/3fc6otD8

Is there any possibility to check if string is valid regular expression inside elm, or to avoid the crash in another way?

Tobias

jonatha...@gmail.com

unread,
Feb 3, 2015, 9:36:18 AM2/3/15
to elm-d...@googlegroups.com
Thank you for finding this!  I created an issue in the bug tracker: https://github.com/elm-lang/core/issues/157.  Feel free to add anything I left out there!

Max Goldstein

unread,
Feb 3, 2015, 6:17:51 PM2/3/15
to elm-d...@googlegroups.com
It would require special casing, but in theory we could validate literal regexes at compile time (add to the warnings issue?). But yes, an invalid regex should always fail to match (basically be a no-op and emit a runtime warning).
Reply all
Reply to author
Forward
0 new messages