Tweak r98602: keep the other IP normalization for non-ranges, such as upper case...
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 1 Oct 2011 05:11:21 +0000 (05:11 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 1 Oct 2011 05:11:21 +0000 (05:11 +0000)
includes/IP.php
tests/phpunit/includes/IPTest.php

index 2f262e3..2889dd4 100644 (file)
@@ -707,11 +707,11 @@ class IP {
         */
        public static function sanitizeRange( $range ) {
                list( /*...*/, $bits ) = self::parseCIDR( $range );
-               if ( $bits === false ) {
-                       return $range; // wasn't actually a range
-               }
                list( $start, /*...*/ ) = self::parseRange( $range );
                $start = self::formatHex( $start );
+               if ( $bits === false ) {
+                       return $start; // wasn't actually a range
+               }
                return "$start/$bits";
        }
 }
index 74dd0ab..c31e2af 100644 (file)
@@ -502,7 +502,7 @@ class IPTest extends MediaWikiTestCase {
                        array( '0:1:2:3:4:c5:f6:7/96', '0:1:2:3:4:C5:0:0/96', 'IPv6 range' ),
                        array( '0:1:2:3:4:5:6:7/120', '0:1:2:3:4:5:6:0/120', 'IPv6 range' ),
                        array( '0:e1:2:3:4:5:e6:7/128', '0:E1:2:3:4:5:E6:7/128', 'IPv6 silly range' ),
-                       array( '0:1:A2:3:4:5:c6:7', '0:1:A2:3:4:5:c6:7', 'IPv6 non range' ),
+                       array( '0:c1:A2:3:4:5:c6:7', '0:C1:A2:3:4:5:C6:7', 'IPv6 non range' ),
                );
        }
 }