Fixed typo in ipv6 private IP range list and added test (bug 30739)
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 6 Sep 2011 23:15:42 +0000 (23:15 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 6 Sep 2011 23:15:42 +0000 (23:15 +0000)
includes/IP.php
tests/phpunit/includes/IPTest.php

index 20760d6..152236f 100644 (file)
@@ -378,7 +378,7 @@ class IP {
                static $privateRanges = false;
                if ( !$privateRanges ) {
                        $privateRanges = array(
-                               array( 'fc::', 'fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' ), # RFC 4193 (local)
+                               array( 'fc00::', 'fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' ), # RFC 4193 (local)
                                array( '0:0:0:0:0:0:0:1', '0:0:0:0:0:0:0:1' ), # loopback
                        );
                }
index 6232d4b..bd1113b 100644 (file)
@@ -272,10 +272,14 @@ class IPTest extends MediaWikiTestCase {
         * @covers IP::isPublic
         */
        public function testPrivateIPs() {
-               $private = array( 'fc::3', 'fc::ff', '::1', '10.0.0.1', '172.16.0.1', '192.168.0.1' );
+               $private = array( 'fc00::3', 'fc00::ff', '::1', '10.0.0.1', '172.16.0.1', '192.168.0.1' );
                foreach ( $private as $p ) {
                        $this->assertFalse( IP::isPublic( $p ), "$p is not a public IP address" );
                }
+               $public = array( '2001:5c0:1000:a::133', 'fc::3' );
+               foreach ( $public as $p ) {
+                       $this->assertTrue( IP::isPublic( $p ), "$p is a public IP address" );
+               }
        }
 
        // Private wrapper used to test CIDR Parsing.