Skip to content

Commit b36d463

Browse files
Release 2.1.2 (#492)
1 parent 53491b6 commit b36d463

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## 2.1.2 - 2022-03-20
11+
12+
### Fixed
13+
14+
- Correct header value validation
15+
1016
## 2.1.1 - 2022-03-20
1117

1218
### Fixed

src/MessageTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private function assertValue(string $value): void
259259
// Clients must not send a request with line folding and a server sending folded headers is
260260
// likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
261261
// folding is not likely to break any legitimate use case.
262-
if (! preg_match('/^(?:[\x21-\x7E\x80-\xFF](?:[\x20\x09]+[\x21-\x7E\x80-\xFF])?)*$/', $value)) {
262+
if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/', $value)) {
263263
throw new \InvalidArgumentException(sprintf('"%s" is not valid header value', $value));
264264
}
265265
}

tests/RequestTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ public function testHostIsAddedFirst(): void
176176
], $r->getHeaders());
177177
}
178178

179+
public function testHeaderValueWithWhitespace(): void
180+
{
181+
$r = new Request('GET', 'https://example.com/', [
182+
'User-Agent' => 'Linux f0f489981e90 5.10.104-linuxkit 1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64'
183+
]);
184+
self::assertSame([
185+
'Host' => ['example.com'],
186+
'User-Agent' => ['Linux f0f489981e90 5.10.104-linuxkit 1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64']
187+
], $r->getHeaders());
188+
}
189+
179190
public function testCanGetHeaderAsCsv(): void
180191
{
181192
$r = new Request('GET', 'http://foo.com/baz?bar=bam', [

0 commit comments

Comments
 (0)