From 894bdaabe4e6116af1af67e77a0dd60d5706c266 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Fri, 12 Aug 2011 14:32:05 +0000 Subject: [PATCH] Fix r91886 thanks to johnduhart: check if it is an IP *before* stripping subpages, otherwise IP range blocking does not work --- includes/Block.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index 105b19a6bd..71e128d626 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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 ); -- 2.20.1