From dae7ffcfc79ceb5b3af59511057497c6e4504989 Mon Sep 17 00:00:00 2001 From: OverlordQ Date: Tue, 5 Jan 2010 05:44:31 +0000 Subject: [PATCH] Split rangeblock error message, allow configuring max size of IPv6 blocks as well. (r58377) --- includes/DefaultSettings.php | 5 ++++- includes/specials/SpecialBlockip.php | 8 ++++++-- languages/messages/MessagesEn.php | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 01510fb238..74c8785e54 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1302,7 +1302,10 @@ $wgSysopRangeBans = true; # Allow sysops to ban IP ranges $wgAutoblockExpiry = 86400; # Number of seconds before autoblock entries expire $wgBlockAllowsUTEdit = false; # Default setting for option on block form to allow self talkpage editing whilst blocked $wgSysopEmailBans = true; # Allow sysops to ban users from accessing Emailuser -$wgBlockCIDRLimit = 16; # Blocks larger than a /16 (64k addresses) will not be allowed +$wgBlockCIDRLimit = array( + 'IPv4' => 16, # Blocks larger than a /16 (64k addresses) will not be allowed + 'IPv6' => 64, # 2^64 = ~1.8x10^19 addresses +); # Pages anonymous user may see as an array, e.g.: # array ( "Main Page", "Wikipedia:Help"); diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index dbd67ec2e4..ceef42db22 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -383,8 +383,10 @@ class IPBlockForm { if( preg_match( "/^($rxIP4)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) { # IPv4 if( $wgSysopRangeBans ) { - if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < $wgBlockCIDRLimit || $matches[2] > 32 ) { + if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] > 32 ) { return array( 'ip_range_invalid' ); + } elseif ( $matches[2] < $wgBlockCIDRLimit['IPv4'] ) { + return array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] ); } $this->BlockAddress = Block::normaliseRange( $this->BlockAddress ); } else { @@ -394,8 +396,10 @@ class IPBlockForm { } elseif( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) { # IPv6 if( $wgSysopRangeBans ) { - if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] < 64 || $matches[2] > 128 ) { + if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] > 128 ) { return array( 'ip_range_invalid' ); + } elseif( $matches[2] < $wgBlockCIDRLimit['IPv6'] ) { + return array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] ); } $this->BlockAddress = Block::normaliseRange( $this->BlockAddress ); } else { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 7abc68da9d..aabfe0bc2e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2958,6 +2958,7 @@ It may have been unblocked already.', 'ipb_blocked_as_range' => 'Error: The IP address $1 is not blocked directly and cannot be unblocked. It is, however, blocked as part of the range $2, which can be unblocked.', 'ip_range_invalid' => 'Invalid IP range.', +'ip_range_toolarge' => 'Range blocks larger than /$1 are not allowed.', 'blockme' => 'Block me', 'proxyblocker' => 'Proxy blocker', 'proxyblocker-disabled' => 'This function is disabled.', -- 2.20.1