http://qs321.pair.com?node_id=11137259


in reply to Is it safe to use external strings for regexes?

Depending on how nasty your users are, allowing arbitrary regular expressions is an unwise choice. The following regex is valid but will use up lots of CPU:

"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" =~ /a*a*a*b/

If you can come up with a whitelist of allowed regexes, that would improve things, or maybe consider running the regex search as a time-limited subprocess.