Skip to content

Commit 2f6cfae

Browse files
Merge branch '4.4' into 5.4
* 4.4: [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 the notification email theme for asynchronously dispatched emails 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 4.4.49 Update VERSION for 4.4.48 Update CONTRIBUTORS for 4.4.48 Update CHANGELOG for 4.4.48
2 parents 75bd663 + 773aca6 commit 2f6cfae

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
@@ -135,6 +135,15 @@ public static function checkIp6(?string $requestIp, string $ip)
135135
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
136136
}
137137

138+
// Check to see if we were given a IP4 $requestIp or $ip by mistake
139+
if (str_contains($requestIp, '.') || str_contains($ip, '.')) {
140+
return self::$checkedIps[$cacheKey] = false;
141+
}
142+
143+
if (!filter_var($requestIp, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
144+
return self::$checkedIps[$cacheKey] = false;
145+
}
146+
138147
if (str_contains($ip, '/')) {
139148
[$address, $netmask] = explode('/', $ip, 2);
140149

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)