Changeset View
Changeset View
Standalone View
Standalone View
src/ip/PhutilCIDRBlock.php
Context not available. | |||||
} | } | ||||
private static function newFromString($str) { | private static function newFromString($str) { | ||||
if (!preg_match('(^[\d.:a-fA-F]+/[\d]+\z)', $str)) { | if (!@preg_match('(^[\d.:a-fA-F]+/[\d]+\z)', $str)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'CIDR block "%s" is not formatted correctly. Expected an IP block '. | 'CIDR block "%s" is not formatted correctly. Expected an IP block '. | ||||
Context not available. | |||||
'23:45:67:89::/24')); | '23:45:67:89::/24')); | ||||
} | } | ||||
list($ip, $mask) = explode('/', $str); | list($ip, $mask) = @explode('/', $str); | ||||
$ip = PhutilIPAddress::newAddress($ip); | $ip = PhutilIPAddress::newAddress($ip); | ||||
if (preg_match('/^0\d/', $mask)) { | if (@preg_match('/^0\d/', $mask)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'CIDR block "%s" is not formatted correctly. The IP block mask '. | 'CIDR block "%s" is not formatted correctly. The IP block mask '. | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0