in reply to Re: Using Regexp Patterns as Variables
in thread Using Regexp Patterns as Variables

You just allowed arbitrary code to be placed in the url. Considering the code appears in a CGI script, that doesn't seem to be a good idea.

If you want a template (that's what '$1' is here), use a template, not eval EXPR!!!

Replies are listed 'Best First'.
Re^3: Using Regexp Patterns as Variables
by Rodster001 (Pilgrim) on Mar 18, 2009 at 16:51 UTC
    It's an admin function. I fully trust the source of where these rules are created. Regular users cannot do this and the function is well protected.

    Think of it like giving them root access. If root wants to do an "rm -rf /" that's the power of root.

    With great power comes great... well, you know.

      Turn on taint #!/usr/bin/perl -T-- just the same.
Re^3: Using Regexp Patterns as Variables
by kyle (Abbot) on Mar 18, 2009 at 16:48 UTC

    That's why I wrote this:

    I can't say I recommend that, however, especially if you don't trust the source of your real $out.

      There's no "if". $ENV{REQUEST_URI} is controlled by remote users.

      Even ignoring the evident trust issues, eval is simply not the right tool.

        Correct. However, since the regex patterns are stored in the DB, put there by trusted users, it is effectively the same as hard coding them (without having to). $ENV{REQUEST_URI} can be mucked with without any security issues (the replacement will just fail).