fix Net_IPv6::compress() to properly handle all-zeros address

The existing implementation of Net_IPv6::compress produces an empty
string when compressing the all-zeros ("::") address; fix this by
checking for empty return values and replacing them with "::".
This commit is contained in:
Daniel Becker 2015-02-08 22:26:26 -08:00 committed by Renato Botelho
parent 07efe7c0eb
commit ce0e5d384d

View File

@ -748,6 +748,12 @@ class Net_IPv6
$cip = preg_replace('/((^:)|(:$))/', '', $cip);
$cip = preg_replace('/((^:)|(:$))/', '::', $cip);
if (empty($cip)) {
$cip = "::";
}
if ('' != $netmask) {
$cip = $cip.'/'.$netmask;