Skip to content

Commit 921ecff

Browse files
zerkmsfabpot
authored andcommitted
[HttpFoundation] IpUtils::checkIp4() should allow networks
1 parent af0e02c commit 921ecff

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Symfony/Component/HttpFoundation/IpUtils.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public static function checkIp($requestIp, $ips)
6262
public static function checkIp4($requestIp, $ip)
6363
{
6464
if (false !== strpos($ip, '/')) {
65+
if ('0.0.0.0/0' === $ip) {
66+
return true;
67+
}
68+
6569
list($address, $netmask) = explode('/', $ip, 2);
6670

6771
if ($netmask < 1 || $netmask > 32) {

src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function testIpv4Provider()
3434
array(true, '192.168.1.1', array('1.2.3.4/1', '192.168.1.0/24')),
3535
array(true, '192.168.1.1', array('192.168.1.0/24', '1.2.3.4/1')),
3636
array(false, '192.168.1.1', array('1.2.3.4/1', '4.3.2.1/1')),
37+
array(true, '1.2.3.4', '0.0.0.0/0'),
38+
array(false, '1.2.3.4', '256.256.256/0'),
39+
array(false, '1.2.3.4', '192.168.1.0/0'),
3740
);
3841
}
3942

0 commit comments

Comments
 (0)