From: Aaron Schulz Date: Tue, 13 Mar 2007 19:25:49 +0000 (+0000) Subject: *More robust IPv6 validation (exclude ambiguous IPs) X-Git-Tag: 1.31.0-rc.0~53772 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=93ffe9c2009039da6f6f8bfb9e573c833b02188c;p=lhc%2Fweb%2Fwiklou.git *More robust IPv6 validation (exclude ambiguous IPs) --- diff --git a/includes/IP.php b/includes/IP.php index 883c3ef1a9..80efd1c762 100644 --- a/includes/IP.php +++ b/includes/IP.php @@ -36,11 +36,13 @@ class IP { */ public static function isIPAddress( $ip ) { if ( !$ip ) return false; - return preg_match( '/^' . IP_ADDRESS_STRING . '$/', $ip); + // IPv6 IPs with two "::" strings are ambiguous and this invalid + return preg_match( '/^' . IP_ADDRESS_STRING . '$/', $ip) && ( substr_count($ip, '::') < 2 ); } public static function isIPv6( $ip ) { - return preg_match( '/^' . RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)$/', $ip); + // IPv6 IPs with two "::" strings are ambiguous and this invalid + return preg_match( '/^' . RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)$/', $ip) && ( substr_count($ip, '::') < 2); } public static function isIPv4( $ip ) {