File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff 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.2.1 - UPCOMING
11+
12+ ### Fixed
13+
14+ - Correct header value validation
15+
1016## 2.2.0 - 2022-03-20
1117
1218### Added
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 ' , [
You can’t perform that action at this time.
0 commit comments