Skip to content

Commit 6d13a93

Browse files
committed
Merge branch '6.4' into 7.3
* 6.4: fix high deps tests [HttpFoundation] Fix double-prefixing of session keys when using redis/memcached [FrameworkBundle] Revert destination file change for secrets:decrypt-to-local [Process] Ignore invalid env var names
2 parents cbfa859 + e579464 commit 6d13a93

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public function start(?callable $callback = null, array $env = []): void
332332

333333
$envPairs = [];
334334
foreach ($env as $k => $v) {
335-
if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) {
335+
if (false !== $v && !\in_array($k = (string) $k, ['', 'argc', 'argv', 'ARGC', 'ARGV'], true) && !str_contains($k, '=') && !str_contains($k, "\0")) {
336336
$envPairs[] = $k.'='.$v;
337337
}
338338
}

Tests/ProcessTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,46 @@ public function testEnvArgument()
16051605
$this->assertSame($env, $p->getEnv());
16061606
}
16071607

1608+
public function testEnvVarNamesCastToString()
1609+
{
1610+
$process = $this->getProcess('echo hello');
1611+
$process->setEnv([123 => 'value']);
1612+
1613+
$process->run();
1614+
1615+
$this->assertSame('hello'.\PHP_EOL, $process->getOutput());
1616+
}
1617+
1618+
public function testEnvVarNamesWithEqualsSigns()
1619+
{
1620+
$process = $this->getProcess('echo hello');
1621+
$process->setEnv(['VAR=NAME' => 'value']);
1622+
1623+
$process->run();
1624+
1625+
$this->assertSame('hello'.\PHP_EOL, $process->getOutput());
1626+
}
1627+
1628+
public function testEnvVarNamesWithNullBytes()
1629+
{
1630+
$process = $this->getProcess('echo hello');
1631+
$process->setEnv(["VAR\0NAME" => 'value']);
1632+
1633+
$process->run();
1634+
1635+
$this->assertSame('hello'.\PHP_EOL, $process->getOutput());
1636+
}
1637+
1638+
public function testEnvVarNamesEmpty()
1639+
{
1640+
$process = $this->getProcess('echo hello');
1641+
$process->setEnv(['' => 'value']);
1642+
1643+
$process->run();
1644+
1645+
$this->assertSame('hello'.\PHP_EOL, $process->getOutput());
1646+
}
1647+
16081648
public function testWaitStoppedDeadProcess()
16091649
{
16101650
$process = $this->getProcess(self::$phpBin.' '.__DIR__.'/ErrorProcessInitiator.php -e '.self::$phpBin);

0 commit comments

Comments
 (0)