Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-08-01 13:09:23 +0300
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-08-01 13:24:39 +0300
commit5daf307a0d27ca6539443a820bb1d9059d07d14a (patch)
treecb72ad35c99c66b9a0d24ddfb855f79111110bba /lib
parentead97ba46d6a90cd52dfbf2323460ecf5a7fbf5a (diff)
Remove call to undefined function, fix typing
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Http/IpUtils.php33
1 files changed, 11 insertions, 22 deletions
diff --git a/lib/private/Http/IpUtils.php b/lib/private/Http/IpUtils.php
index cc2bba06dbb..97a3cb9dba1 100644
--- a/lib/private/Http/IpUtils.php
+++ b/lib/private/Http/IpUtils.php
@@ -16,6 +16,9 @@ namespace OC\Http;
* @author Fabien Potencier <fabien@symfony.com>
*/
class IpUtils {
+ /**
+ * @var array<string,bool>
+ */
private static $checkedIps = [];
/**
@@ -31,13 +34,7 @@ class IpUtils {
*
* @return bool
*/
- public static function checkIp(?string $requestIp, $ips) {
- if (null === $requestIp) {
- trigger_deprecation('symfony/http-foundation', '5.4', 'Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.', __METHOD__);
-
- return false;
- }
-
+ public static function checkIp(string $requestIp, $ips) {
if (!\is_array($ips)) {
$ips = [$ips];
}
@@ -61,13 +58,7 @@ class IpUtils {
*
* @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet
*/
- public static function checkIp4(?string $requestIp, string $ip) {
- if (null === $requestIp) {
- trigger_deprecation('symfony/http-foundation', '5.4', 'Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.', __METHOD__);
-
- return false;
- }
-
+ public static function checkIp4(string $requestIp, string $ip) {
$cacheKey = $requestIp.'-'.$ip;
if (isset(self::$checkedIps[$cacheKey])) {
return self::$checkedIps[$cacheKey];
@@ -81,9 +72,11 @@ class IpUtils {
[$address, $netmask] = explode('/', $ip, 2);
if ('0' === $netmask) {
- return self::$checkedIps[$cacheKey] = filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4);
+ return self::$checkedIps[$cacheKey] = (bool)filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4);
}
+ $netmask = (int)$netmask;
+
if ($netmask < 0 || $netmask > 32) {
return self::$checkedIps[$cacheKey] = false;
}
@@ -113,13 +106,7 @@ class IpUtils {
*
* @throws \RuntimeException When IPV6 support is not enabled
*/
- public static function checkIp6(?string $requestIp, string $ip) {
- if (null === $requestIp) {
- trigger_deprecation('symfony/http-foundation', '5.4', 'Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.', __METHOD__);
-
- return false;
- }
-
+ public static function checkIp6(string $requestIp, string $ip) {
$cacheKey = $requestIp.'-'.$ip;
if (isset(self::$checkedIps[$cacheKey])) {
return self::$checkedIps[$cacheKey];
@@ -136,6 +123,8 @@ class IpUtils {
return (bool) unpack('n*', @inet_pton($address));
}
+ $netmask = (int)$netmask;
+
if ($netmask < 1 || $netmask > 128) {
return self::$checkedIps[$cacheKey] = false;
}