8000 Merge branch '4.4' into 5.3 · symfony/symfony@0605903 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0605903

Browse files
committed
Merge branch '4.4' into 5.3
* 4.4: do not call preg_match() on null
2 parents 6ff1b63 + 677ca9c commit 0605903

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ public function isMethodCacheable()
15071507
public function getProtocolVersion()
15081508
{
15091509
if ($this->isFromTrustedProxy()) {
1510-
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via'), $matches);
1510+
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via') ?? '', $matches);
15111511

15121512
if ($matches) {
15131513
return 'HTTP/'.$matches[2];

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,17 +2248,22 @@ public function testProtocolVersion($serverProtocol, $trustedProxy, $via, $expec
22482248
$request = new Request();
22492249
$request->server->set('SERVER_PROTOCOL', $serverProtocol);
22502250
$request->server->set('REMOTE_ADDR', '1.1.1.1');
2251-
$request->headers->set('Via', $via);
2251+
2252+
if (null !== $via) {
2253+
$request->headers->set('Via', $via);
2254+
}
22522255

22532256
$this->assertSame($expected, $request->getProtocolVersion());
22542257
}
22552258

22562259
public function protocolVersionProvider()
22572260
{
22582261
return [
2259-
'untrusted without via' => ['HTTP/2.0', false, '', 'HTTP/2.0'],
2262+
'untrusted with empty via' => ['HTTP/2.0', false, '', 'HTTP/2.0'],
2263+
'untrusted without via' => ['HTTP/2.0', false, null, 'HTTP/2.0'],
22602264
'untrusted with via' => ['HTTP/2.0', false, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/2.0'],
2261-
'trusted without via' => ['HTTP/2.0', true, '', 'HTTP/2.0'],
2265+
'trusted with empty via' => ['HTTP/2.0', true, '', 'HTTP/2.0'],
2266+
'trusted without via' => ['HTTP/2.0', true, null, 'HTTP/2.0'],
22622267
'trusted with via' => ['HTTP/2.0', true, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'],
22632268
'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'],
22642269
'trusted with broken via' => ['HTTP/2.0', true, 'HTTP/1^0 foo', 'HTTP/2.0'],

0 commit comments

Comments
 (0)
0