Skip to content

Commit ea2dc31

Browse files
Merge branch '4.4' into 5.0
* 4.4: [Validator] Fix auto-mapping constraints should not be validated [Debug] Updated the README to deprecate the component [Cache] fix memory leak when using PhpFilesAdapter [Yaml] Implement multiline string as scalar block for tagged values [HttpFoundation] Use `Cache-Control: must-revalidate` only if explicit lifetime has been given [FrameworkBundle] Use UserInterface to @return in getUser method [CI] Replace php7.4snapshot with php7.4 in Travis configuration [ExpressionLanguage][Node][BinaryNode] Process division by zero Fixing bad order of operations with null coalescing operator forward caught exception [Validator][ConstraintValidator] Stop passing unnecessary timezone argument to \DateTime add tags before processing them [FrameworkBundle][ContainerLintCommand] Reinitialize bundles when the container is reprepared [Process] change the syntax of portable prepared command lines [MonologBridge] Fix debug processor datetime type
2 parents 1568a2e + b84501a commit ea2dc31

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Process.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,12 +1591,12 @@ private function escapeArgument(?string $argument): string
15911591

15921592
private function replacePlaceholders(string $commandline, array $env)
15931593
{
1594-
return preg_replace_callback('/"\$([_a-zA-Z]++[_a-zA-Z0-9]*+)"/', function ($matches) use ($commandline, $env) {
1594+
return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) {
15951595
if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) {
1596-
throw new InvalidArgumentException(sprintf('Command line is missing a value for key %s: %s.', $matches[0], $commandline));
1596+
throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": %s.', $matches[1], $commandline));
15971597
}
15981598

1599-
return '\\' === \DIRECTORY_SEPARATOR ? $this->escapeArgument($env[$matches[1]]) : $matches[0];
1599+
return $this->escapeArgument($env[$matches[1]]);
16001600
}, $commandline);
16011601
}
16021602

Tests/ProcessTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,23 +1463,23 @@ public function provideEscapeArgument()
14631463

14641464
public function testPreparedCommand()
14651465
{
1466-
$p = Process::fromShellCommandline('echo "$abc"DEF');
1466+
$p = Process::fromShellCommandline('echo "${:abc}"DEF');
14671467
$p->run(null, ['abc' => 'ABC']);
14681468

14691469
$this->assertSame('ABCDEF', rtrim($p->getOutput()));
14701470
}
14711471

14721472
public function testPreparedCommandMulti()
14731473
{
1474-
$p = Process::fromShellCommandline('echo "$abc""$def"');
1474+
$p = Process::fromShellCommandline('echo "${:abc}""${:def}"');
14751475
$p->run(null, ['abc' => 'ABC', 'def' => 'DEF']);
14761476

14771477
$this->assertSame('ABCDEF', rtrim($p->getOutput()));
14781478
}
14791479

14801480
public function testPreparedCommandWithQuoteInIt()
14811481
{
1482-
$p = Process::fromShellCommandline('php -r "$code" "$def"');
1482+
$p = Process::fromShellCommandline('php -r "${:code}" "${:def}"');
14831483
$p->run(null, ['code' => 'echo $argv[1];', 'def' => '"DEF"']);
14841484

14851485
$this->assertSame('"DEF"', rtrim($p->getOutput()));
@@ -1488,16 +1488,16 @@ public function testPreparedCommandWithQuoteInIt()
14881488
public function testPreparedCommandWithMissingValue()
14891489
{
14901490
$this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
1491-
$this->expectExceptionMessage('Command line is missing a value for key "$abc": echo "$abc".');
1492-
$p = Process::fromShellCommandline('echo "$abc"');
1491+
$this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}".');
1492+
$p = Process::fromShellCommandline('echo "${:abc}"');
14931493
$p->run(null, ['bcd' => 'BCD']);
14941494
}
14951495

14961496
public function testPreparedCommandWithNoValues()
14971497
{
14981498
$this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
1499-
$this->expectExceptionMessage('Command line is missing a value for key "$abc": echo "$abc".');
1500-
$p = Process::fromShellCommandline('echo "$abc"');
1499+
$this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}".');
1500+
$p = Process::fromShellCommandline('echo "${:abc}"');
15011501
$p->run(null, []);
15021502
}
15031503

0 commit comments

Comments
 (0)