8000 [Process] Use new ProcessUtils::escapeArgument to escape ProcessBuild… · norberttech/symfony@209799b · GitHub
[go: up one dir, main page]

Skip to content

Commit 209799b

Browse files
committed
[Process] Use new ProcessUtils::escapeArgument to escape ProcessBuilder prefix
1 parent 61c56fc commit 209799b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Symfony/Component/Process/ProcessBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ public function getProcess()
160160

161161
$options = $this->options;
162162

163-
$script = ($this->prefix ? escapeshellarg($this->prefix) . ' ' : '')
164-
.implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $this->arguments));
163+
$arguments = $this->prefix ? array_merge(array($this->prefix), $this->arguments) : $this->arguments;
164+
$script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
165165

166166
if ($this->inheritEnv) {
167167
$env = $this->env ? $this->env + $_ENV : null;

src/Symfony/Component/Process/Tests/ProcessBuilderTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,17 @@ public function testShouldEscapeArguments()
139139
$this->assertSame("'%path%' 'foo \" bar'", $proc->getCommandLine());
140140
}
141141
}
142+
143+
public function testShouldEscapeArgumentsAndPrefix()
144+
{
145+
$pb = new ProcessBuilder(array('arg'));
146+
$pb->setPrefix('%prefix%');
147+
$proc = $pb->getProcess();
148+
149+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
150+
$this->assertSame('^%"prefix"^% "arg"', $proc->getCommandLine());
151+
} else {
152+
$this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine());
153+
}
154+
}
142155
}

0 commit comments

Comments
 (0)
0