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 ddc9e38

Browse filesBrowse files
lazyhammerfabpot
authored andcommitted
Modify Request::getClientIp() to use IpUtils::checkIp()
Adds the ability to use CIDR notation in the trusted proxy list
1 parent 79cadc4 commit ddc9e38
Copy full SHA for ddc9e38

File tree

Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed

‎src/Symfony/Component/HttpFoundation/Request.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Request.php
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,16 @@ public function getClientIps()
688688

689689
$trustedProxies = !self::$trustedProxies ? array($ip) : self::$trustedProxies;
690690
$ip = $clientIps[0];
691-
$clientIps = array_values(array_diff($clientIps, $trustedProxies));
691+
692+
foreach ($clientIps as $key => $clientIp) {
693+
foreach ($trustedProxies as $trustedProxy) {
694+
if (IpUtils::checkIp($clientIp, $trustedProxy)) {
695+
unset($clientIps[$key]);
696+
697+
continue 2;
698+
}
699+
}
700+
}
692701

693702
return $clientIps ? array_reverse($clientIps) : array($ip);
694703
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.