in reply to Re: $1 in variable regex replacement string
in thread $1 in variable regex replacement string
For example you would not want it passed:
$repl = '\";`hacked`;\"';
You can make this a whole lot safer (maybe even totally safe) with a suitable sanitization of $repl
sub munge_string { my ( $str, $pat, $repl ) = @_; # make $repl safe to eval $repl =~ tr/\0//d; $repl =~ s/([^A-Za-z0-9\$])/\\$1/g; $repl = '"' . $repl . '"'; $str =~ s/$pat/$repl/eeg; return $str; }
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: $1 in variable regex replacement string
by tadman (Prior) on Feb 12, 2003 at 22:32 UTC | |
by jsprat (Curate) on Feb 13, 2003 at 01:57 UTC | |
by tachyon (Chancellor) on Feb 12, 2003 at 22:48 UTC | |
by belden (Friar) on Feb 13, 2003 at 01:32 UTC | |
by tadman (Prior) on Feb 14, 2003 at 03:26 UTC | |
by belden (Friar) on Feb 15, 2003 at 01:01 UTC |