Skip to content

Commit 4c55dff

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Fix polyfill-php73 requirement [CI] Fix package-tests workflow checks for contracts do not call preg_match() on null Fix UPGRADE files for framework.messenger.reset_on_message option [Messenger] [DI] Add auto-registration for BatchHandlerInterface Remove duplicated entry in UPGRADE-6.0.md Handle alias in completion script
2 parents 9df0b92 + 5dad378 commit 4c55dff

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ public function isMethodCacheable(): bool
14161416
public function getProtocolVersion(): ?string
14171417
{
14181418
if ($this->isFromTrustedProxy()) {
1419-
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via'), $matches);
1419+
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via') ?? '', $matches);
14201420

14211421
if ($matches) {
14221422
return 'HTTP/'.$matches[2];

Tests/RequestTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,17 +2253,22 @@ public function testProtocolVersion($serverProtocol, $trustedProxy, $via, $expec
22532253
$request = new Request();
22542254
$request->server->set('SERVER_PROTOCOL', $serverProtocol);
22552255
$request->server->set('REMOTE_ADDR', '1.1.1.1');
2256-
$request->headers->set('Via', $via);
2256+
2257+
if (null !== $via) {
2258+
$request->headers->set('Via', $via);
2259+
}
22572260

22582261
$this->assertSame($expected, $request->getProtocolVersion());
22592262
}
22602263

22612264
public function protocolVersionProvider()
22622265
{
22632266
return [
2264-
'untrusted without via' => ['HTTP/2.0', false, '', 'HTTP/2.0'],
2267+
'untrusted with empty via' => ['HTTP/2.0', false, '', 'HTTP/2.0'],
2268+
'untrusted without via' => ['HTTP/2.0', false, null, 'HTTP/2.0'],
22652269
'untrusted with via' => ['HTTP/2.0', false, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/2.0'],
2266-
'trusted without via' => ['HTTP/2.0', true, '', 'HTTP/2.0'],
2270+
'trusted with empty via' => ['HTTP/2.0', true, '', 'HTTP/2.0'],
2271+
'trusted without via' => ['HTTP/2.0', true, null, 'HTTP/2.0'],
22672272
'trusted with via' => ['HTTP/2.0', true, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'],
22682273
'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'],
22692274
'trusted with broken via' => ['HTTP/2.0', true, 'HTTP/1^0 foo', 'HTTP/2.0'],

0 commit comments

Comments
 (0)