Skip to content

Commit

Permalink
Merge branch '2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Mar 20, 2022
2 parents 6565c7e + b36d463 commit 8f199b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 2.2.1 - UPCOMING

### Fixed

- Correct header value validation

## 2.2.0 - 2022-03-20

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/MessageTrait.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 8f199b1

Please sign in to comment.