Skip to content

Commit a9d633e

Browse files
committed
Merge branch '7.4' into 8.0
* 7.4: fix high deps tests [ObjectMapper] Fix mapping for missing source properties [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 [FrameworkBundle] Don't list ExpressionConfigurator if expression-language is not installed on reference config shape [JsonStreamer] Fix memory leak by caching stream readers/writers [FrameworkBundle] Skip extensions with empty configuration in reference.php Also bypass `Return-Path` header within `MicrosoftGraphApiTransport`
2 parents 0cbbd88 + f532042 commit a9d633e

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

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
@@ -1571,6 +1571,46 @@ public function testEnvArgument()
15711571
$this->assertSame($env, $p->getEnv());
15721572
}
15731573

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

0 commit comments

Comments
 (0)