Take the IPv4 part of mapped addresses rather than broken '.'->':' replace
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 8 Aug 2009 01:22:15 +0000 (01:22 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 8 Aug 2009 01:22:15 +0000 (01:22 +0000)
includes/IP.php

index d5c61d2..c20ebcd 100644 (file)
@@ -541,11 +541,10 @@ class IP {
                if ( self::isValid( $addr ) )
                        return $addr;
 
-               // Annoying IPv6 representations like ::ffff:1.2.3.4
+               // Turn mapped addresses from ::ce:ffff:1.2.3.4 to 1.2.3.4
                if ( strpos($addr,':') !==false && strpos($addr,'.') !==false ) {
-                       $addr = str_replace( '.', ':', $addr );
-                       if( IP::isIPv6( $addr ) )
-                               return $addr;
+                       $addr = substr( $addr, strrpos($addr,':')+1 );
+                       if( self::isIPv4($addr) ) return $addr;
                }
 
                // IPv6 loopback address