Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: $1 in variable regex replacement string

by dvergin (Monsignor)
on Feb 12, 2003 at 20:35 UTC ( [id://234819]=note: print w/replies, xml ) Need Help??


in reply to Re: $1 in variable regex replacement string
in thread $1 in variable regex replacement string

So I pose roughly the same question here that I posed to tadman -- if I go the /e or /ee route, what are the things that $repl might contain that could potentially do horrible things.

If I filter out '(?{...})' constructs, is that enough? If so, this solution is do-able.

  • Comment on Re: Re: $1 in variable regex replacement string

Replies are listed 'Best First'.
Re: Re: Re: $1 in variable regex replacement string
by CountZero (Bishop) on Feb 13, 2003 at 07:01 UTC

    Really bad thing could happen even outside '(?{...})' constructs.

    For example (this is something totally innocent, but you get the idea):

    use strict; my $str = 'abcadefaghi'; my $pat = qr/(a.)/; my $repl = 'system dir '; $str =~ s/$pat/$repl/eeg;

    Of course you could try to filter out all system, exec and backticks, but that is only solving a small part of the possible problems as anything inside the $repl-variable gets run as a perl-program.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://234819]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-18 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found