From 2e8901667605b8f63730cf7af99d5d641be800bb Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 8 Aug 2009 01:22:15 +0000 Subject: [PATCH] Take the IPv4 part of mapped addresses rather than broken '.'->':' replace --- includes/IP.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/IP.php b/includes/IP.php index d5c61d2ff0..c20ebcda2d 100644 --- a/includes/IP.php +++ b/includes/IP.php @@ -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 -- 2.20.1