diff --git a/lib/Froxlor/Settings/Store.php b/lib/Froxlor/Settings/Store.php index 3371b921..56bb5fed 100644 --- a/lib/Froxlor/Settings/Store.php +++ b/lib/Froxlor/Settings/Store.php @@ -262,9 +262,9 @@ class Store foreach ($ips as $ip) { $org_ip = $ip; $ip_cidr = explode("/", $ip); - if (count($ip_cidr) == 2) { + if (count($ip_cidr) === 2) { $ip = $ip_cidr[0]; - if(in_array((int)strlen((string)$ip_cidr[1]),array(1,2))) { + if (strlen($ip_cidr[1]) <= 2) { $ip_cidr[1] = \Froxlor\Validate\Validate::cidr2NetmaskAddr($org_ip); } $newfieldvalue[] = $ip . '/' . $ip_cidr[1]; diff --git a/tests/Froxlor/ValidateTest.php b/tests/Froxlor/ValidateTest.php index a47dba82..6600d5f1 100644 --- a/tests/Froxlor/ValidateTest.php +++ b/tests/Froxlor/ValidateTest.php @@ -86,6 +86,13 @@ class ValidateTest extends TestCase $this->assertEquals("12.34.56.78/24", $result); } + public function testValidateIpv6Disallowed() + { + $this->expectException("Exception"); + $this->expectExceptionCode(400); + $result = Validate::validate_ip2("2620:0:2d0:200::7/32", false, 'invalidip', false, false, true, true); + } + public function testValidateIpLocalhostAllowed() { $result = Validate::validate_ip2("127.0.0.1/32", false, 'invalidip', true, false, true, true);