Skip to content

Commit eb88e3b

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Messenger] Use :memory: for SQLite tests [Mailer] Stream timeout not detected due to checking only string result of function fgets don not set http_version instead of setting it to null [DependencyInjection] don't move locator tag for service subscriber Fix search scope when performing fallback mapping driver detection Fix the notification email theme for asynchronously dispatched emails Update the CI setup to use the new output file Update actions in the CI to move away from the deprecated runtime Use 6.3 for new features [HttpFoundation] Check IPv6 is valid before comparing it Run tests with UTC to avoid daylight saving time messing with assertions Bump Symfony version to 5.4.16 Update VERSION for 5.4.15 Update CHANGELOG for 5.4.15 Bump Symfony version to 4.4.49 Update VERSION for 4.4.48 Update CONTRIBUTORS for 4.4.48 Update CHANGELOG for 4.4.48 [DependencyInjection] Don't autoconfigure tag when it's already set with attributes
2 parents a93829f + 2f6cfae commit eb88e3b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

IpUtils.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ public static function checkIp6(string $requestIp, string $ip): bool
113113
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
114114
}
115115

116+
// Check to see if we were given a IP4 $requestIp or $ip by mistake
117+
if (str_contains($requestIp, '.') || str_contains($ip, '.')) {
118+
return self::$checkedIps[$cacheKey] = false;
119+
}
120+
121+
if (!filter_var($requestIp, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
122+
return self::$checkedIps[$cacheKey] = false;
123+
}
124+
116125
if (str_contains($ip, '/')) {
117126
[$address, $netmask] = explode('/', $ip, 2);
118127

Tests/IpUtilsTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public function getIpv6Data()
7474
[false, '}__test|O:21:"JDatabaseDriverMysqli":3:{s:2', '::1'],
7575
[false, '2a01:198:603:0:396e:4789:8e99:890f', 'unknown'],
7676
[false, '', '::1'],
77+
[false, '127.0.0.1', '::1'],
78+
[false, '0.0.0.0/8', '::1'],
79+
[false, '::1', '127.0.0.1'],
80+
[false, '::1', '0.0.0.0/8'],
7781
];
7882
}
7983

0 commit comments

Comments
 (0)