r20361 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20360‎ | r20361 | r20362 >
Date:07:44, 12 March 2007
Author:aaron
Status:old
Tags:
Comment:
*Use strval() to ensure wfBaseConvert() recieves a string
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -64,9 +64,9 @@
6565 if ( count( $parts ) != 2 ) {
6666 return false;
6767 }
68 - $network = self::toUnsigned( $parts[0] );
69 - $bits = $parts[1] + 96;
 68+ $network = self::toUnsigned( $parts[0] );
7069 if ( $network !== false && is_numeric( $parts[1] ) && $parts[1] >= 0 && $parts[1] <= 32 ) {
 70+ $bits = $parts[1] + 96;
7171 return self::toOctet( $network ) . "/$bits";
7272 } else {
7373 return false;
@@ -108,10 +108,11 @@
109109
110110 /**
111111 * Given an unsigned integer, returns an IPv6 address in octet notation
112 - * @param $ip integer ipv6 IP address.
 112+ * @param $ip integer IP address.
113113 * @return string
114114 */
115115 public function toOctet( $ip_int ) {
 116+ $ip_int = strval($ip_int);
116117 // Convert integer to binary
117118 $ip_int = wfBaseConvert($ip_int, 10, 2, 128);
118119 // Seperate into 8 octets