[Process] Add tests on ProcessUtils::escapeArgument
This commit is contained in:
parent
85fb495a30
commit
de681cbf5c
@ -57,7 +57,7 @@ class ProcessUtils
|
||||
$part .= '\\';
|
||||
}
|
||||
$part = escapeshellarg($part);
|
||||
if ($part[0] === '"' && $part[strlen($part) - 1] === '"') {
|
||||
if ('"' === $part[0] && '"' === $part[strlen($part) - 1]) {
|
||||
$part = substr($part, 1, -1);
|
||||
$quote = true;
|
||||
}
|
||||
@ -65,7 +65,7 @@ class ProcessUtils
|
||||
}
|
||||
}
|
||||
if ($quote) {
|
||||
$escapedArgument = '"' . $escapedArgument . '"';
|
||||
$escapedArgument = '"'.$escapedArgument.'"';
|
||||
}
|
||||
|
||||
return $escapedArgument;
|
||||
|
@ -27,6 +27,7 @@ class ProcessUtilsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
return array(
|
||||
array('"\"php\" \"-v\""', '"php" "-v"'),
|
||||
array('"foo bar"', 'foo bar'),
|
||||
array('^%"path"^%', '%path%'),
|
||||
array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'),
|
||||
@ -36,6 +37,7 @@ class ProcessUtilsTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
return array(
|
||||
array("'\"php\" \"-v\"'", '"php" "-v"'),
|
||||
array("'foo bar'", 'foo bar'),
|
||||
array("'%path%'", '%path%'),
|
||||
array("'<|>\" \"'\\''f'", '<|>" "\'f'),
|
||||
|
Reference in New Issue
Block a user