Skip to content

Commit d81aa36

Browse files
Merge branch '6.2' into 6.3
* 6.2: (25 commits) Bump Symfony version to 6.2.7 Update VERSION for 6.2.6 Update CHANGELOG for 6.2.6 Bump Symfony version to 5.4.21 Update VERSION for 5.4.20 Update CHANGELOG for 5.4.20 [HttpFoundation] Fix bad return type in IpUtils::checkIp4() [DependencyInjection] Fix order of arguments when mixing positional and named ones [HttpClient] Fix collecting data non-late for the profiler [Security/Http] Fix compat of persistent remember-me with legacy tokens Bump Symfony version to 6.2.6 Update VERSION for 6.2.5 Update CHANGELOG for 6.2.5 Bump Symfony version to 6.1.12 Update VERSION for 6.1.11 Update CHANGELOG for 6.1.11 Bump Symfony version to 6.0.20 Update VERSION for 6.0.19 Update CHANGELOG for 6.0.19 Bump Symfony version to 5.4.20 ...
2 parents fad43be + e8dd1f5 commit d81aa36

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

IpUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function checkIp4(string $requestIp, string $ip): bool
7272
[$address, $netmask] = explode('/', $ip, 2);
7373

7474
if ('0' === $netmask) {
75-
return self::$checkedIps[$cacheKey] = filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4);
75+
return self::$checkedIps[$cacheKey] = false !== filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4);
7676
}
7777

7878
if ($netmask < 0 || $netmask > 32) {

Tests/IpUtilsTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,21 @@ public function anonymizedIpData()
137137
['::123.234.235.236', '::123.234.235.0'], // deprecated IPv4-compatible IPv6 address
138138
];
139139
}
140+
141+
/**
142+
* @dataProvider getIp4SubnetMaskZeroData
143+
*/
144+
public function testIp4SubnetMaskZero($matches, $remoteAddr, $cidr)
145+
{
146+
$this->assertSame($matches, IpUtils::checkIp4($remoteAddr, $cidr));
147+
}
148+
149+
public function getIp4SubnetMaskZeroData()
150+
{
151+
return [
152+
[true, '1.2.3.4', '0.0.0.0/0'],
153+
[true, '1.2.3.4', '192.168.1.0/0'],
154+
[false, '1.2.3.4', '256.256.256/0'], // invalid CIDR notation
155+
];
156+
}
140157
}

0 commit comments

Comments
 (0)