bug #12572 [HttpFoundation] fix checkip6 (Neime)

This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes #12572).

Discussion
----------

[HttpFoundation] fix checkip6

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

I have this error ContextErrorException: Warning: inet_pton(): Unrecognized address X.X.X.X:X
in IpUtils.php line 110

X.X.X.X:X is detected as a ipv6 because HTTP_X_FORWARDED_FOR have a port.

Commits
-------

1da0ba4 [Debug] fix checkip6
This commit is contained in:
Fabien Potencier 2014-12-29 09:16:17 +01:00
commit ff079dd41e

View File

@ -39,7 +39,7 @@ class IpUtils
$ips = array($ips);
}
$method = false !== strpos($requestIp, ':') ? 'checkIp6' : 'checkIp4';
$method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4';
foreach ($ips as $ip) {
if (self::$method($requestIp, $ip)) {