in reply to Re: Find and replace MD5 hash from file
in thread Find and replace MD5 hash from file
If you then single quote your s/// expression to protect from shell interpolation
Adding single quotes does not protect from shell interpolation.
That will fail if $hash1 or $hash2 can contain «'», I don't think that's possible, but I don't know for sure.
That's why I use
$s =~ s/'/'\\''/g; return "'$s'";
instead of
return "'$s'";
Update: philipbailey has since pointed out that the hash cannot contains quotes. While you can't context text to a shell literal using the second snippet in general, it appears to be safe in this particular circumstance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Find and replace MD5 hash from file
by philipbailey (Curate) on Jun 29, 2011 at 19:45 UTC | |
by ikegami (Patriarch) on Jun 29, 2011 at 20:19 UTC | |
by philipbailey (Curate) on Jun 29, 2011 at 20:36 UTC | |
by ikegami (Patriarch) on Jun 29, 2011 at 20:40 UTC | |
by philipbailey (Curate) on Jun 29, 2011 at 20:53 UTC | |
|