From 0bbc7cbe3474f7971b04e558eb2a87e935daaa47 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 12 Mar 2007 19:31:30 +0000 Subject: [PATCH] *Automatic address expansion, remove redundant check --- includes/Block.php | 2 ++ includes/SpecialBlockip.php | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index 00befac4d6..4d7325e175 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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; diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index 13cb0b16d5..41a0f5d7b1 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -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)"; -- 2.20.1