*Automatic address expansion, remove redundant check
authorAaron Schulz <aaron@users.mediawiki.org>
Mon, 12 Mar 2007 19:31:30 +0000 (19:31 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Mon, 12 Mar 2007 19:31:30 +0000 (19:31 +0000)
includes/Block.php
includes/SpecialBlockip.php

index 00befac..4d7325e 100644 (file)
@@ -26,6 +26,8 @@ class Block
                $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0 )
        {
                $this->mId = 0;
+               # Expand valid IPv6 addresses
+               $address = IP::expandIP( $address );
                $this->mAddress = $address;
                $this->mUser = $user;
                $this->mBy = $by;
index 13cb0b1..41a0f5d 100644 (file)
@@ -199,11 +199,9 @@ class IPBlockForm {
 
                $userId = 0;
                $this->BlockAddress = trim( $this->BlockAddress );
-               # Expand valid IPv6 addresses
-               if ( IP::isIPAddress( $this->BlockAddress ) ) {
-                       $this->BlockAddress = IP::expandIP( $this->BlockAddress );
-               }
-               # The above validation is good enough that those below will suffice from here
+               # Expand valid IPv6 addresses, usernames are left as is
+               $this->BlockAddress = IP::expandIP( $this->BlockAddress );
+               # isIPv4() and IPv6() are used for final validation
                $rxIP4 = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
                $rxIP6 = '\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}';
                $rxIP = "($rxIP4|$rxIP6)";