in reply to Untaint a string match, regular expression.

Either you let a user specify a regex , or you don't

Either you trust the user or you don't

re

If you have questions about pcre, start with its docs

But, if you cant even use the correct vocabulary, nothing is safe

  • Comment on Re: Untaint a string match, regular expression.

Replies are listed 'Best First'.
Re^2: Untaint a string match, regular expression.
by cheako (Beadle) on May 18, 2015 at 00:14 UTC

    I think it would be trivial to write a subroutine in perl that takes a string and splits it on '^', '$', '.*' and then recombines the string as a regex, with the rest of the string regex escaped.

    The above would allow for user to specify a regex and be secure for untrusted users. This can also be expanded to include many more features.

      Ok, if you think so, what is your question?
        It's trivial for a few things, but quickly becomes larger than life. The question is how do we securely interpret an re with a large enough feature-set to be useful for most things.

        Looks like this may not be a concern and that's indeed an acceptable answer.