Skip to content

Commit 452d19f

Browse files
thecaliskanEmre Çalışkan
authored andcommitted
fixed Via regex
1 parent 6b7c97f commit 452d19f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Request.php

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

14711471
if ($matches) {
14721472
return 'HTTP/'.$matches[2];

Tests/RequestTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,8 @@ public static function protocolVersionProvider()
24022402
'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'],
24032403
'trusted with broken via' => ['HTTP/2.0', true, 'HTTP/1^0 foo', 'HTTP/2.0'],
24042404
'trusted with partially-broken via' => ['HTTP/2.0', true, '1.0 fred, foo', 'HTTP/1.0'],
2405+
'trusted with simple via' => ['HTTP/2.0', true, 'HTTP/1.0', 'HTTP/1.0'],
2406+
'trusted with only version via' => ['HTTP/2.0', true, '1.0', 'HTTP/1.0'],
24052407
];
24062408
}
24072409

0 commit comments

Comments
 (0)