Index: trunk/phase3/includes/IP.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * Given a string, determine if it as valid IP |
34 | 34 | * Unlike isValid(), this looks for networks too |
35 | 35 | * @param $ip IP address. |
36 | | - * @return string |
| 36 | + * @return string |
37 | 37 | */ |
38 | 38 | public static function isIPAddress( $ip ) { |
39 | 39 | if ( !$ip ) return false; |
— | — | @@ -41,11 +41,13 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | public static function isIPv6( $ip ) { |
| 45 | + if ( !$ip ) return false; |
45 | 46 | // IPv6 IPs with two "::" strings are ambiguous and this invalid |
46 | 47 | return preg_match( '/^' . RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)$/', $ip) && ( substr_count($ip, '::') < 2); |
47 | 48 | } |
48 | 49 | |
49 | 50 | public static function isIPv4( $ip ) { |
| 51 | + if ( !$ip ) return false; |
50 | 52 | return preg_match( '/^' . RE_IP_ADD . '(\/' . RE_IP_PREFIX . '|)$/', $ip); |
51 | 53 | } |
52 | 54 | |
— | — | @@ -100,7 +102,7 @@ |
101 | 103 | public static function sanitizeIP( $ip ) { |
102 | 104 | if ( !$ip ) return null; |
103 | 105 | // Only IPv6 addresses can be expanded |
104 | | - if ( !self::isIPv6( $ip ) ) return $ip; |
| 106 | + if ( !self::isIPv6($ip) ) return $ip; |
105 | 107 | // Remove any whitespaces, convert to upper case |
106 | 108 | $ip = strtoupper( trim($ip) ); |
107 | 109 | // Expand zero abbreviations |