Fix r91886 thanks to johnduhart: check if it is an IP *before* stripping subpages...
authorRobin Pepermans <robin@users.mediawiki.org>
Fri, 12 Aug 2011 14:32:05 +0000 (14:32 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Fri, 12 Aug 2011 14:32:05 +0000 (14:32 +0000)
includes/Block.php

index 105b19a..71e128d 100644 (file)
@@ -1057,6 +1057,19 @@ class Block {
                        return array( null, null );
                }
 
+               if ( IP::isValid( $target ) ) {
+                       # We can still create a User if it's an IP address, but we need to turn
+                       # off validation checking (which would exclude IP addresses)
+                       return array(
+                               User::newFromName( IP::sanitizeIP( $target ), false ),
+                               Block::TYPE_IP
+                       );
+
+               } elseif ( IP::isValidBlock( $target ) ) {
+                       # Can't create a User from an IP range
+                       return array( IP::sanitizeRange( $target ), Block::TYPE_RANGE );
+               }
+
                # Consider the possibility that this is not a username at all
                # but actually an old subpage (bug #29797)
                if( strpos( $target, '/' ) !== false ){
@@ -1072,18 +1085,6 @@ class Block {
                        # since hash characters are not valid in usernames or titles generally.
                        return array( $userObj, Block::TYPE_USER );
 
-               } elseif ( IP::isValid( $target ) ) {
-                       # We can still create a User if it's an IP address, but we need to turn
-                       # off validation checking (which would exclude IP addresses)
-                       return array(
-                               User::newFromName( IP::sanitizeIP( $target ), false ),
-                               Block::TYPE_IP
-                       );
-
-               } elseif ( IP::isValidBlock( $target ) ) {
-                       # Can't create a User from an IP range
-                       return array( IP::sanitizeRange( $target ), Block::TYPE_RANGE );
-
                } elseif ( preg_match( '/^#\d+$/', $target ) ) {
                        # Autoblock reference in the form "#12345"
                        return array( substr( $target, 1 ), Block::TYPE_AUTO );