Skip to content

Commit fadbccc

Browse files
[HttpKernel] fix forwarding trusted headers as server parameters
1 parent ee945de commit fadbccc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ private function normalizeAndFilterClientIps(array $clientIps, $ip)
19911991
if ($i) {
19921992
$clientIps[$key] = $clientIp = substr($clientIp, 0, $i);
19931993
}
1994-
} elseif ('[' == $clientIp[0]) {
1994+
} elseif (0 === strpos($clientIp, '[')) {
19951995
// Strip brackets and :port from IPv6 addresses.
19961996
$i = strpos($clientIp, ']', 1);
19971997
$clientIps[$key] = $clientIp = substr($clientIp, 1, $i - 1);

Tests/RequestTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ public function getClientIpsForwardedProvider()
868868

869869
public function getClientIpsProvider()
870870
{
871-
// $expected $remoteAddr $httpForwardedFor $trustedProxies
871+
// $expected $remoteAddr $httpForwardedFor $trustedProxies
872872
return array(
873873
// simple IPv4
874874
array(array('88.88.88.88'), '88.88.88.88', null, null),
@@ -882,8 +882,8 @@ public function getClientIpsProvider()
882882

883883
// forwarded for with remote IPv4 addr not trusted
884884
array(array('127.0.0.1'), '127.0.0.1', '88.88.88.88', null),
885-
// forwarded for with remote IPv4 addr trusted
886-
array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88', array('127.0.0.1')),
885+
// forwarded for with remote IPv4 addr trusted + comma
886+
array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88,', array('127.0.0.1')),
887887
// forwarded for with remote IPv4 and all FF addrs trusted
888888
array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88', array('127.0.0.1', '88.88.88.88')),
889889
// forwarded for with remote IPv4 range trusted

0 commit comments

Comments
 (0)