From c47386e27ef46647d0bc87b5e5d657e38fa14685 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 1 Oct 2011 05:11:21 +0000 Subject: [PATCH] Tweak r98602: keep the other IP normalization for non-ranges, such as upper case for v6. This keeps it a bit more consistent. --- includes/IP.php | 6 +++--- tests/phpunit/includes/IPTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/IP.php b/includes/IP.php index 2f262e3217..2889dd4b77 100644 --- a/includes/IP.php +++ b/includes/IP.php @@ -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"; } } diff --git a/tests/phpunit/includes/IPTest.php b/tests/phpunit/includes/IPTest.php index 74dd0ab9bd..c31e2af4d6 100644 --- a/tests/phpunit/includes/IPTest.php +++ b/tests/phpunit/includes/IPTest.php @@ -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' ), ); } } -- 2.20.1