[Process] Fix parsing args on Windows
This commit is contained in:
parent
22b67a4430
commit
8826da1c81
@ -1633,14 +1633,17 @@ class Process implements \IteratorAggregate
|
||||
$varCount = 0;
|
||||
$varCache = array();
|
||||
$cmd = preg_replace_callback(
|
||||
'/"(
|
||||
'/"(?:(
|
||||
[^"%!^]*+
|
||||
(?:
|
||||
(?: !LF! | "(?:\^[%!^])?+" )
|
||||
[^"%!^]*+
|
||||
)++
|
||||
)"/x',
|
||||
) | [^"]*+ )"/x',
|
||||
function ($m) use (&$envBackup, &$env, &$varCache, &$varCount, $uid) {
|
||||
if (!isset($m[1])) {
|
||||
return $m[0];
|
||||
}
|
||||
if (isset($varCache[$m[0]])) {
|
||||
return $varCache[$m[0]];
|
||||
}
|
||||
|
@ -1484,6 +1484,24 @@ class ProcessTest extends TestCase
|
||||
$this->assertSame($arg, $p->getOutput());
|
||||
}
|
||||
|
||||
public function testRawCommandLine()
|
||||
{
|
||||
$p = new Process(sprintf('"%s" -r %s "a" "" "b"', self::$phpBin, escapeshellarg('print_r($argv);')));
|
||||
$p->run();
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Array
|
||||
(
|
||||
[0] => -
|
||||
[1] => a
|
||||
[2] =>
|
||||
[3] => b
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertSame($expected, $p->getOutput());
|
||||
}
|
||||
|
||||
public function provideEscapeArgument()
|
||||
{
|
||||
yield array('a"b%c%');
|
||||
|
Reference in New Issue
Block a user