File tree 3 files changed +18
-1
lines changed
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
7
7
8
8
## Unreleased
9
9
10
+ ## 2.1.2 - 2022-03-20
11
+
12
+ ### Fixed
13
+
14
+ - Correct header value validation
15
+
10
16
## 2.1.1 - 2022-03-20
11
17
12
18
### Fixed
Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ private function assertValue(string $value): void
259
259
// Clients must not send a request with line folding and a server sending folded headers is
260
260
// likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
261
261
// 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 )) {
263
263
throw new \InvalidArgumentException (sprintf ('"%s" is not valid header value ' , $ value ));
264
264
}
265
265
}
Original file line number Diff line number Diff line change @@ -176,6 +176,17 @@ public function testHostIsAddedFirst(): void
176
176
], $ r ->getHeaders ());
177
177
}
178
178
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
+
179
190
public function testCanGetHeaderAsCsv (): void
180
191
{
181
192
$ r = new Request ('GET ' , 'http://foo.com/baz?bar=bam ' , [
You can’t perform that action at this time.
0 commit comments