[Process] Use new ProcessUtils::escapeArgument to escape ProcessBuilder prefix
This commit is contained in:
parent
61c56fc54a
commit
209799b18e
@ -160,8 +160,8 @@ class ProcessBuilder
|
||||
|
||||
$options = $this->options;
|
||||
|
||||
$script = ($this->prefix ? escapeshellarg($this->prefix) . ' ' : '')
|
||||
.implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $this->arguments));
|
||||
$arguments = $this->prefix ? array_merge(array($this->prefix), $this->arguments) : $this->arguments;
|
||||
$script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
|
||||
|
||||
if ($this->inheritEnv) {
|
||||
$env = $this->env ? $this->env + $_ENV : null;
|
||||
|
@ -139,4 +139,17 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("'%path%' 'foo \" bar'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldEscapeArgumentsAndPrefix()
|
||||
{
|
||||
$pb = new ProcessBuilder(array('arg'));
|
||||
$pb->setPrefix('%prefix%');
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertSame('^%"prefix"^% "arg"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user