[HttpFoundation] IpUtils::checkIp4() should allow networks
This commit is contained in:
parent
af0e02c35e
commit
921ecff9e2
@ -62,6 +62,10 @@ class IpUtils
|
|||||||
public static function checkIp4($requestIp, $ip)
|
public static function checkIp4($requestIp, $ip)
|
||||||
{
|
{
|
||||||
if (false !== strpos($ip, '/')) {
|
if (false !== strpos($ip, '/')) {
|
||||||
|
if ('0.0.0.0/0' === $ip) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
list($address, $netmask) = explode('/', $ip, 2);
|
list($address, $netmask) = explode('/', $ip, 2);
|
||||||
|
|
||||||
if ($netmask < 1 || $netmask > 32) {
|
if ($netmask < 1 || $netmask > 32) {
|
||||||
|
@ -34,6 +34,9 @@ class IpUtilsTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(true, '192.168.1.1', array('1.2.3.4/1', '192.168.1.0/24')),
|
array(true, '192.168.1.1', array('1.2.3.4/1', '192.168.1.0/24')),
|
||||||
array(true, '192.168.1.1', array('192.168.1.0/24', '1.2.3.4/1')),
|
array(true, '192.168.1.1', array('192.168.1.0/24', '1.2.3.4/1')),
|
||||||
array(false, '192.168.1.1', array('1.2.3.4/1', '4.3.2.1/1')),
|
array(false, '192.168.1.1', array('1.2.3.4/1', '4.3.2.1/1')),
|
||||||
|
array(true, '1.2.3.4', '0.0.0.0/0'),
|
||||||
|
array(false, '1.2.3.4', '256.256.256/0'),
|
||||||
|
array(false, '1.2.3.4', '192.168.1.0/0'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user