note 67811 added to function.escapeshellcmd
| From: | abennett at clarku dot edu | Date: | Wed, 05 Jul 2006 18:59:33 +0000 |
| Subject: | note 67811 added to function.escapeshellcmd | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114390@lists.php.net to get a copy of this message | ||
I've got a php script that needs to pass a username and password via exec to a perl script.
The problem is valid password characters were getting escaped...
Here's a little perl function I wrote to fix it.
sub unescape_string {
my $string = shift;
# all these interpolated regex's are slow, so if there's no
# backslash in the string don't bother with it
# index() is faster then a regex
if ( ! index($string,'\\\\') ) {
return $string;
}
my @characters = ('#', '&', ';', '`',
'|', '*', '?', '~', '<', '>',
'^', '(', ')',
'[', ']', '{', '}', '$',
'\\', ',', ' ', '\x0A', '\xFF' );
my $character;
foreach $character (@characters) {
$character = quotemeta($character);
my $pattern = "\\\\(" . $character . ")";
$string =~ s/$pattern/$1/g;
}
return $string;
}
Hope this is useful.
----
Server IP: 64.71.164.2
Probable Submitter: 140.232.0.75
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.escapeshellcmd.php
Edit -- http://master.php.net/note/edit/67811
Del: integrated -- http://master.php.net/note/delete/67811/integrated
Del: useless -- http://master.php.net/note/delete/67811/useless
Del: bad code -- http://master.php.net/note/delete/67811/bad+code
Del: spam -- http://master.php.net/note/delete/67811/spam
Del: non-english -- http://master.php.net/note/delete/67811/non-english
Del: in docs -- http://master.php.net/note/delete/67811/in+docs
Del: other reasons-- http://master.php.net/note/delete/67811
Reject -- http://master.php.net/note/reject/67811
Search -- http://master.php.net/manage/user-notes.php