https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114625

Revision: 114625
Author:   tstarling
Date:     2012-03-30 06:38:46 +0000 (Fri, 30 Mar 2012)
Log Message:
-----------
Temporary fix for bug 35578. Reintroduce validation to processForm(). 

Modified Paths:
--------------
    branches/wmf/1.19wmf1/includes/specials/SpecialBlock.php

Modified: branches/wmf/1.19wmf1/includes/specials/SpecialBlock.php
===================================================================
--- branches/wmf/1.19wmf1/includes/specials/SpecialBlock.php    2012-03-30 
03:30:56 UTC (rev 114624)
+++ branches/wmf/1.19wmf1/includes/specials/SpecialBlock.php    2012-03-30 
06:38:46 UTC (rev 114625)
@@ -546,7 +546,7 @@
         * @return Bool|String
         */
        public static function processForm( array $data, IContextSource 
$context ){
-               global $wgBlockAllowsUTEdit;
+               global $wgBlockAllowsUTEdit, $wgBlockCIDRLimit;
 
                $performer = $context->getUser();
 
@@ -558,7 +558,14 @@
                $data['Confirm'] = !in_array( $data['Confirm'], array( '', '0', 
null, false ), true );
 
                list( $target, $type ) = self::getTargetAndType( 
$data['Target'] );
+               ob_end_clean();
+               var_dump( compact( 'target', 'type' ) );
+               exit;
                if( $type == Block::TYPE_USER ){
+                       if( !$target->getId() ){
+                               return array( array( 'nosuchusershort', 
$target->getName() ) );
+                       }
+
                        $user = $target;
                        $target = $user->getName();
                        $userId = $user->getId();
@@ -576,6 +583,30 @@
                                return array( 'ipb-blockingself' );
                        }
                } elseif( $type == Block::TYPE_RANGE ){
+                       list( $ip, $range ) = explode( '/', $target, 2 );
+
+                       if( ( IP::isIPv4( $ip ) && $wgBlockCIDRLimit['IPv4'] == 
32 )
+                               || ( IP::isIPv6( $ip ) && 
$wgBlockCIDRLimit['IPV6'] == 128 ) )
+                       {
+                               # Range block effectively disabled
+                               return array( 'range_block_disabled' );
+                       }
+
+                       if( ( IP::isIPv4( $ip ) && $range > 32 )
+                               || ( IP::isIPv6( $ip ) && $range > 128 ) )
+                       {
+                               # Dodgy range
+                               return array( 'ip_range_invalid' );
+                       }
+
+                       if( IP::isIPv4( $ip ) && $range < 
$wgBlockCIDRLimit['IPv4'] ) {
+                               return array( array( 'ip_range_toolarge', 
$wgBlockCIDRLimit['IPv4'] ) );
+                       }
+
+                       if( IP::isIPv6( $ip ) && $range < 
$wgBlockCIDRLimit['IPv6'] ) {
+                               return array( array( 'ip_range_toolarge', 
$wgBlockCIDRLimit['IPv6'] ) );
+                       }
+
                        $userId = 0;
                } elseif( $type == Block::TYPE_IP ){
                        $target = $target->getName();


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to