r54623 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54622‎ | r54623 | r54624 >
Date:01:22, 8 August 2009
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Take the IPv4 part of mapped addresses rather than broken '.'->':' replace
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -541,11 +541,10 @@
542542 if ( self::isValid( $addr ) )
543543 return $addr;
544544
545 - // Annoying IPv6 representations like ::ffff:1.2.3.4
 545+ // Turn mapped addresses from ::ce:ffff:1.2.3.4 to 1.2.3.4
546546 if ( strpos($addr,':') !==false && strpos($addr,'.') !==false ) {
547 - $addr = str_replace( '.', ':', $addr );
548 - if( IP::isIPv6( $addr ) )
549 - return $addr;
 547+ $addr = substr( $addr, strrpos($addr,':')+1 );
 548+ if( self::isIPv4($addr) ) return $addr;
550549 }
551550
552551 // IPv6 loopback address

Comments

#Comment by Brion VIBBER (talk | contribs)   02:19, 19 August 2009

Sounds ok, but this sort of thing is just *begging* for a unit test. :)

Status & tagging log