Merge "Do not use OutputPage to output exceptions in Installer"
[lhc/web/wiklou.git] / includes / utils / IP.php
index 002dcd9..871f71b 100644 (file)
@@ -367,7 +367,6 @@ class IP {
        /**
         * Determine if an IP address really is an IP address, and if it is public,
         * i.e. not RFC 1918 or similar
-        * Comes from ProxyTools.php
         *
         * @param $ip String
         * @return Boolean
@@ -482,7 +481,6 @@ class IP {
        /**
         * Given an IP address in dotted-quad/octet notation, returns an unsigned integer.
         * Like ip2long() except that it actually works and has a consistent error return value.
-        * Comes from ProxyTools.php
         *
         * @param string $ip quad dotted IP address.
         * @return Mixed: string/int/false
@@ -491,6 +489,8 @@ class IP {
                if ( self::isIPv6( $ip ) ) {
                        $n = self::toUnsigned6( $ip );
                } else {
+                       // Bug 60035: an IP with leading 0's fails in ip2long sometimes (e.g. *.08)
+                       $ip = preg_replace( '/(?<=\.)0+(?=[1-9])/', '', $ip );
                        $n = ip2long( $ip );
                        if ( $n < 0 ) {
                                $n += pow( 2, 32 );