Skip to content

Commit f532042

Browse files
committed
Merge branch '7.3' into 7.4
* 7.3: fix high deps tests [HttpFoundation] Fix double-prefixing of session keys when using redis/memcached [TypeInfo] Fix static type resolution when called class is in different namespace [FrameworkBundle] Revert destination file change for secrets:decrypt-to-local [Process] Ignore invalid env var names [JsonStreamer] Fix memory leak by caching stream readers/writers
2 parents 2f8e1a6 + 6d13a93 commit f532042

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
@@ -338,7 +338,7 @@ public function start(?callable $callback = null, array $env = []): void
338338

339339
$envPairs = [];
340340
foreach ($env as $k => $v) {
341-
if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) {
341+
if (false !== $v && !\in_array($k = (string) $k, ['', 'argc', 'argv', 'ARGC', 'ARGV'], true) && !str_contains($k, '=') && !str_contains($k, "\0")) {
342342
$envPairs[] = $k.'='.$v;
343343
}
344344
}

Tests/ProcessTest.php

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

1577+
public function testEnvVarNamesCastToString()
1578+
{
1579+
$process = $this->getProcess('echo hello');
1580+
$process->setEnv([123 => 'value']);
1581+
1582+
$process->run();
1583+
1584+
$this->assertSame('hello'.\PHP_EOL, $process->getOutput());
1585+
}
1586+
1587+
public function testEnvVarNamesWithEqualsSigns()
1588+
{
1589+
$process = $this->getProcess('echo hello');
1590+
$process->setEnv(['VAR=NAME' => 'value']);
1591+
1592+
$process->run();
1593+
1594+
$this->assertSame('hello'.\PHP_EOL, $process->getOutput());
1595+
}
1596+
1597+
public function testEnvVarNamesWithNullBytes()
1598+
{
1599+
$process = $this->getProcess('echo hello');
1600+
$process->setEnv(["VAR\0NAME" => 'value']);
1601+
1602+
$process->run();
1603+
1604+
$this->assertSame('hello'.\PHP_EOL, $process->getOutput());
1605+
}
1606+
1607+
public function testEnvVarNamesEmpty()
1608+
{
1609+
$process = $this->getProcess('echo hello');
1610+
$process->setEnv(['' => 'value']);
1611+
1612+
$process->run();
1613+
1614+
$this->assertSame('hello'.\PHP_EOL, $process->getOutput());
1615+
}
1616+
15771617
public function testWaitStoppedDeadProcess()
15781618
{
15791619
$process = $this->getProcess(self::$phpBin.' '.__DIR__.'/ErrorProcessInitiator.php -e '.self::$phpBin);

0 commit comments

Comments
 (0)