[Process] Fix parsing args on Windows

This commit is contained in:
Nicolas Grekas 2017-07-11 15:19:03 +02:00
parent 22b67a4430
commit 8826da1c81
2 changed files with 23 additions and 2 deletions

View File

@ -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]];
}

View File

@ -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%');