* Fixed regression in blocking of username '0'
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 3 Aug 2007 08:51:55 +0000 (08:51 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 3 Aug 2007 08:51:55 +0000 (08:51 +0000)
IP::sanitizeIP() for some reason is used to return IP-or-something-that's-not-an-IP, but was incorrectly checking for empties. Thus for '0' input it returned NULL instead of '0'.

RELEASE-NOTES
includes/IP.php

index 7854833..1e13708 100644 (file)
@@ -346,6 +346,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Toggles in RTL preferences indented to the right, hidden in IE in some
   cases.
 * Fix RTL display of the upload form.
+* Fixed regression in blocking of username '0'
+
 
 == API changes since 1.10 ==
 
index a84fb6d..4c24ed9 100644 (file)
@@ -114,13 +114,14 @@ class IP {
         * @return string 
         */     
        public static function sanitizeIP( $ip ) {
-               if ( !$ip ) return null;
+               $ip = trim( $ip );
+               if ( $ip === '' ) return null;
                // Trim and return IPv4 addresses
-               if ( self::isIPv4($ip) ) return trim($ip);
+               if ( self::isIPv4($ip) ) return $ip;
                // Only IPv6 addresses can be expanded
                if ( !self::isIPv6($ip) ) return $ip;
                // Remove any whitespaces, convert to upper case
-               $ip = strtoupper( trim($ip) );
+               $ip = strtoupper( $ip );
                // Expand zero abbreviations
                if ( strpos( $ip, '::' ) !== false ) {
                $ip = str_replace('::', str_repeat(':0', 8 - substr_count($ip, ':')) . ':', $ip);