8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 78747e6 commit 7b5328fCopy full SHA for 7b5328f
src/Symfony/Component/HttpFoundation/Request.php
@@ -546,9 +546,16 @@ public function getClientIp()
546
if ($this->server->has('HTTP_CLIENT_IP')) {
547
return $this->server->get('HTTP_CLIENT_IP');
548
} elseif ($this->server->has('HTTP_X_FORWARDED_FOR')) {
549
- $clientIp = explode(',', $this->server->get('HTTP_X_FORWARDED_FOR'), 2);
+ $clientIp = explode(',', $this->server->get('HTTP_X_FORWARDED_FOR'));
550
551
- return isset($clientIp[0]) ? trim($clientIp[0]) : '';
+ foreach ($clientIp as $ipAddress) {
552
+ $cleanIpAddress = trim($ipAddress);
553
+
554
+ if (false !== filter_var($cleanIpAddress, FILTER_VALIDATE_IP)) {
555
+ return $cleanIpAddress;
556
+ }
557
558
+ return '';
559
}
560
561
0 commit comments