r20435 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20434‎ | r20435 | r20436 >
Date:05:23, 14 March 2007
Author:aaron
Status:old (Comments)
Tags:
Comment:
*Run isIPv6() before trim/uppercasing
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -32,7 +32,7 @@
3333 * Given a string, determine if it as valid IP
3434 * Unlike isValid(), this looks for networks too
3535 * @param $ip IP address.
36 - * @return string
 36+ * @return string
3737 */
3838 public static function isIPAddress( $ip ) {
3939 if ( !$ip ) return false;
@@ -41,11 +41,13 @@
4242 }
4343
4444 public static function isIPv6( $ip ) {
 45+ if ( !$ip ) return false;
4546 // IPv6 IPs with two "::" strings are ambiguous and this invalid
4647 return preg_match( '/^' . RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)$/', $ip) && ( substr_count($ip, '::') < 2);
4748 }
4849
4950 public static function isIPv4( $ip ) {
 51+ if ( !$ip ) return false;
5052 return preg_match( '/^' . RE_IP_ADD . '(\/' . RE_IP_PREFIX . '|)$/', $ip);
5153 }
5254
@@ -100,7 +102,7 @@
101103 public static function sanitizeIP( $ip ) {
102104 if ( !$ip ) return null;
103105 // Only IPv6 addresses can be expanded
104 - if ( !self::isIPv6( $ip ) ) return $ip;
 106+ if ( !self::isIPv6($ip) ) return $ip;
105107 // Remove any whitespaces, convert to upper case
106108 $ip = strtoupper( trim($ip) );
107109 // Expand zero abbreviations

Follow-up revisions

RevisionCommit summaryAuthorDate
r76560* Changes in IP.php:...aaron01:33, 12 November 2010

Comments

#Comment by Aaron Schulz (talk | contribs)   13:58, 11 November 2010

This actually seems to have no purpose at all.

Status & tagging log