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 0026c7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 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>
7 changes: 4 additions & 3 deletions src/Server/Http/Psr7/MessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ public function withBody(StreamInterface $body): MessageInterface
private function setHeaders(array $headers): void
{
foreach ($headers as $name => $value) {
$name = (string) $name;
$normalizedName = $this->normalizeHeaderName($name);
$value = $this->normalizeHeaderValue($value);
$values = $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], $values);
} else {
$this->headerNames[$normalizedName] = $name;
$this->headers[$name] = $value;
$this->headers[$name] = $values;
}
}
}
Expand Down

0 comments on commit 0026c7a

Please sign in to comment.