r102519 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102518‎ | r102519 | r102520 >
Date:15:00, 9 November 2011
Author:reedy
Status:ok
Tags:
Comment:
REL1_18 MFT r98602, r98603, r98605
Modified paths:
  • /branches/REL1_18/phase3 (modified) (history)
  • /branches/REL1_18/phase3/includes (modified) (history)
  • /branches/REL1_18/phase3/includes/IP.php (modified) (history)
  • /branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /branches/REL1_18/phase3/tests/phpunit/includes/IPTest.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/tests/phpunit/includes/IPTest.php
@@ -482,4 +482,27 @@
483483 );
484484 }
485485
 486+ /**
 487+ * Test for IP::sanitizeRange()
 488+ * @dataProvider provideIPCIDRs
 489+ */
 490+ function testSanitizeRange( $input, $expected, $description ) {
 491+ $this->assertEquals( $expected, IP::sanitizeRange( $input ), $description );
 492+ }
 493+
 494+ /**
 495+ * Provider for IP::testSanitizeRange()
 496+ */
 497+ function provideIPCIDRs() {
 498+ return array(
 499+ array( '35.56.31.252/16', '35.56.0.0/16', 'IPv4 range' ),
 500+ array( '135.16.21.252/24', '135.16.21.0/24', 'IPv4 range' ),
 501+ array( '5.36.71.252/32', '5.36.71.252/32', 'IPv4 silly range' ),
 502+ array( '5.36.71.252', '5.36.71.252', 'IPv4 non-range' ),
 503+ array( '0:1:2:3:4:c5:f6:7/96', '0:1:2:3:4:C5:0:0/96', 'IPv6 range' ),
 504+ array( '0:1:2:3:4:5:6:7/120', '0:1:2:3:4:5:6:0/120', 'IPv6 range' ),
 505+ array( '0:e1:2:3:4:5:e6:7/128', '0:E1:2:3:4:5:E6:7/128', 'IPv6 silly range' ),
 506+ array( '0:c1:A2:3:4:5:c6:7', '0:C1:A2:3:4:5:C6:7', 'IPv6 non range' ),
 507+ );
 508+ }
486509 }
Property changes on: branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php
___________________________________________________________________
Modified: svn:mergeinfo
487510 Merged /trunk/phase3/includes/resourceloader/ResourceLoader.php:r98602-98603,98605
Index: branches/REL1_18/phase3/includes/IP.php
@@ -691,10 +691,13 @@
692692 * @param $range String: IP address to normalize
693693 * @return string
694694 */
695 - public static function sanitizeRange( $range ){
 695+ public static function sanitizeRange( $range ) {
696696 list( /*...*/, $bits ) = self::parseCIDR( $range );
697697 list( $start, /*...*/ ) = self::parseRange( $range );
698698 $start = self::formatHex( $start );
 699+ if ( $bits === false ) {
 700+ return $start; // wasn't actually a range
 701+ }
699702 return "$start/$bits";
700703 }
701704 }
Property changes on: branches/REL1_18/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
702705 Merged /trunk/phase3/includes:r98602-98603,98605
Property changes on: branches/REL1_18/phase3
___________________________________________________________________
Modified: svn:mergeinfo
703706 Merged /trunk/phase3:r98602-98603,98605

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98602Made provideIPCIDRs() not add a '/' if there is no prefix length. Fixes bug 3...aaron04:54, 1 October 2011
r98603Reverted stuff from r98602 committed by mistakeaaron05:03, 1 October 2011
r98605Tweak r98602: keep the other IP normalization for non-ranges, such as upper c...aaron05:11, 1 October 2011

Status & tagging log