Skip to content

Commit d990eb9

Browse files
committed
fixed Via regex
1 parent 12b8bc8 commit d990eb9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ public function isMethodCacheable(): bool
13841384
public function getProtocolVersion(): ?string
13851385
{
13861386
if ($this->isFromTrustedProxy()) {
1387-
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via') ?? '', $matches);
1387+
preg_match('~^(HTTP/)?([1-9]\.[0-9])\b~', $this->headers->get('Via') ?? '', $matches);
13881388

13891389
if ($matches) {
13901390
return 'HTTP/'.$matches[2];

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,8 @@ public static function protocolVersionProvider()
24172417
'trusted with via and protocol name' => ['HTTP/2.0', true, 'HTTP/1.0 fred, HTTP/1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'],
24182418
'trusted with broken via' => ['HTTP/2.0', true, 'HTTP/1^0 foo', 'HTTP/2.0'],
24192419
'trusted with partially-broken via' => ['HTTP/2.0', true, '1.0 fred, foo', 'HTTP/1.0'],
2420+
'trusted with simple via' => ['HTTP/2.0', true, 'HTTP/1.0', 'HTTP/1.0'],
2421+
'trusted with only version via' => ['HTTP/2.0', true, '1.0', 'HTTP/1.0'],
24202422
];
24212423
}
24222424

0 commit comments

Comments
 (0)