From 986596de01529f6e837a5cadfef9ec714ace7914 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 20 Mar 2022 21:51:18 +0000 Subject: [PATCH] Release 1.8.5 (#491) --- src/MessageTrait.php | 2 +- tests/RequestTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/MessageTrait.php b/src/MessageTrait.php index 7bb8a05c..ca7969fe 100644 --- a/src/MessageTrait.php +++ b/src/MessageTrait.php @@ -262,7 +262,7 @@ private function assertValue($value) // 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)); } } diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 0d747c07..7371dcd3 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -175,6 +175,17 @@ public function testHostIsAddedFirst() ], $r->getHeaders()); } + public function testHeaderValueWithWhitespace() + { + $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() { $r = new Request('GET', 'http://foo.com/baz?bar=bam', [