Skip to content

Commit

Permalink
Fix server crash when header with only digits in name sended
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Mar 15, 2024
1 parent 1922714 commit 47f5ad8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@
<directory name="src" />
</errorLevel>
</PropertyNotSetInConstructor>
<RedundantCastGivenDocblockType>
<errorLevel type="suppress">
<directory name="src" />
</errorLevel>
</RedundantCastGivenDocblockType>
</issueHandlers>
</psalm>
8 changes: 4 additions & 4 deletions src/Server/Http/Psr7/MessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ public function withBody(StreamInterface $body): MessageInterface
private function setHeaders(array $headers): void
{
foreach ($headers as $name => $value) {
$normalizedName = $this->normalizeHeaderName($name);
$value = $this->normalizeHeaderValue($value);
$normalizedName = $this->normalizeHeaderName((string) $name);
$valuse = $this->normalizeHeaderValue($value);
if (isset($this->headerNames[$normalizedName])) {
$name = $this->headerNames[$normalizedName];
$this->headers[$name] = \array_merge($this->headers[$name], $value);
$this->headers[$name] = \array_merge($this->headers[$name], $valuse);
} else {
$this->headerNames[$normalizedName] = $name;
$this->headers[$name] = $value;
$this->headers[$name] = $valuse;
}
}
}
Expand Down

0 comments on commit 47f5ad8

Please sign in to comment.