Permalink
Browse files

bug #23477 [Process] Fix parsing args on Windows (nicolas-grekas)

This PR was merged into the 3.3 branch.

Discussion
----------

[Process] Fix parsing args on Windows

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23455
| License       | MIT
| Doc PR        | -

Commits
-------

8826da1 [Process] Fix parsing args on Windows
  • Loading branch information...
nicolas-grekas committed Jul 12, 2017
2 parents 2b3afd2 + 8826da1 commit e659ec175fe7ec5d97775896d11d630f6c1c2bf1
Showing with 23 additions and 2 deletions.
  1. +5 −2 src/Symfony/Component/Process/Process.php
  2. +18 −0 src/Symfony/Component/Process/Tests/ProcessTest.php
@@ -1633,14 +1633,17 @@ private function prepareWindowsCommandLine($cmd, array &$envBackup, array &$env
$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 @@ public function testEscapeArgumentWhenInheritEnvDisabled($arg)
$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%');

0 comments on commit e659ec1

Please sign in to comment.