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
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-02 17:07:39 +0300
commit3b42eb01c7e40bc36a5c76bd99d2bbf498faa1b0 (patch)
tree186af22649e0611df9d2abf14febdcf481300375 /lib/private
parent6de71bdaa0b0c2147f57100f971021adb874d612 (diff)
Remove call to undefined function, fix typing
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private')
-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;
}