* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @author Ashar Voultoiz <hashar at free dot fr>, Aaron Schulz
+ * @author Antoine Musso <hashar at free dot fr>, Aaron Schulz
*/
// Some regex definition to "play" with IP address and IP address blocks
*
* A bare IPv6 address is accepted despite the lack of square brackets.
*
- * @param $both The string with the host and port
+ * @param $both string The string with the host and port
* @return array
*/
public static function splitHostAndPort( $both ) {
static $privateRanges = false;
if ( !$privateRanges ) {
$privateRanges = array(
- array( 'fc::', 'fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' ), # RFC 4193 (local)
+ array( 'fc00::', 'fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' ), # RFC 4193 (local)
array( '0:0:0:0:0:0:0:1', '0:0:0:0:0:0:0:1' ), # loopback
);
}
* @param $range String: IP address to normalize
* @return string
*/
- public static function sanitizeRange( $range ){
+ public static function sanitizeRange( $range ) {
list( /*...*/, $bits ) = self::parseCIDR( $range );
list( $start, /*...*/ ) = self::parseRange( $range );
$start = self::formatHex( $start );
+ if ( $bits === false ) {
+ return $start; // wasn't actually a range
+ }
return "$start/$bits";
}
}