Skip to content

Commit

Permalink
Release 2.1.2 (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Mar 20, 2022
1 parent 53491b6 commit b36d463
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 2.1.2 - 2022-03-20

### Fixed

- Correct header value validation

## 2.1.1 - 2022-03-20

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/MessageTrait.php
Expand Up @@ -259,7 +259,7 @@ private function assertValue(string $value): void
// Clients must not send a request with line folding and a server sending folded headers is
// likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
// folding is not likely to break any legitimate use case.
if (! preg_match('/^(?:[\x21-\x7E\x80-\xFF](?:[\x20\x09]+[\x21-\x7E\x80-\xFF])?)*$/', $value)) {
if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/', $value)) {
throw new \InvalidArgumentException(sprintf('"%s" is not valid header value', $value));
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/RequestTest.php
Expand Up @@ -176,6 +176,17 @@ public function testHostIsAddedFirst(): void
], $r->getHeaders());
}

public function testHeaderValueWithWhitespace(): void
{
$r = new Request('GET', 'https://example.com/', [
'User-Agent' => 'Linux f0f489981e90 5.10.104-linuxkit 1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64'
]);
self::assertSame([
'Host' => ['example.com'],
'User-Agent' => ['Linux f0f489981e90 5.10.104-linuxkit 1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64']
], $r->getHeaders());
}

public function testCanGetHeaderAsCsv(): void
{
$r = new Request('GET', 'http://foo.com/baz?bar=bam', [
Expand Down

0 comments on commit b36d463

Please sign in to comment.