Skip to content

Commit

Permalink
Only allow string key and lowercase on header construct
Browse files Browse the repository at this point in the history
  • Loading branch information
lkm committed Feb 14, 2020
1 parent 46b8ffc commit e375691
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Client/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class Headers implements ArrayAccess

public function __construct(array $headers = [])
{
$this->headers = $headers;
foreach ($headers as $k => $v) {
$this->offsetSet($k, $v);
}

$this->set(static::HEADER_XFF, $this->getRemoteAddress() ?? '');
}

Expand Down Expand Up @@ -152,7 +155,9 @@ public function offsetGet($offset)
*/
public function offsetSet($offset, $value)
{
$this->headers[strtolower($offset)] = $value;
if (is_string($offset) && $offset !== '') {
$this->headers[strtolower($offset)] = $value;
}
}

/**
Expand Down

0 comments on commit e375691

Please sign in to comment.