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 @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
1010## Unreleased
1111
12+ ## 1.8.5 - 2022-03-20
13+
14+ ### Fixed
15+
16+ - Correct header value validation
17+
1218## 1.8.4 - 2022-03-20
1319
1420### Fixed
Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ private function assertValue($value)
263263 // Clients must not send a request with line folding and a server sending folded headers is
264264 // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
265265 // folding is not likely to break any legitimate use case.
266- if (! preg_match ('/^(?:[\x21-\x7E\x80-\xFF](?:[\ x20\x09]+[ \x21-\x7E\x80-\xFF])?) *$/ ' , $ value )) {
266+ if (! preg_match ('/^[\ x20\x09\x21-\x7E\x80-\xFF]*$/ ' , $ value )) {
267267 throw new \InvalidArgumentException (sprintf ('"%s" is not valid header value ' , $ value ));
268268 }
269269 }
Original file line number Diff line number Diff line change @@ -174,6 +174,17 @@ public function testHostIsAddedFirst()
174174 ], $ r ->getHeaders ());
175175 }
176176
177+ public function testHeaderValueWithWhitespace ()
178+ {
179+ $ r = new Request ('GET ' , 'https://example.com/ ' , [
180+ 'User-Agent ' => 'Linux f0f489981e90 5.10.104-linuxkit 1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64 '
181+ ]);
182+ self ::assertSame ([
183+ 'Host ' => ['example.com ' ],
184+ 'User-Agent ' => ['Linux f0f489981e90 5.10.104-linuxkit 1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64 ' ]
185+ ], $ r ->getHeaders ());
186+ }
187+
177188 public function testCanGetHeaderAsCsv ()
178189 {
179190 $ r = new Request ('GET ' , 'http://foo.com/baz?bar=bam ' , [
You can’t perform that action at this time.
0 commit comments