From: Côme Chilliet Date: Tue, 28 Jun 2022 09:35:45 +0000 (+0200) Subject: Refactor local IP if and set strict to true for in_array X-Git-Tag: v25.0.0beta1~74^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d0830432a7ce4dece2af7a5ca3c0f3831dbd1291;p=nextcloud-server.git Refactor local IP if and set strict to true for in_array Signed-off-by: Côme Chilliet --- diff --git a/lib/private/Http/Client/LocalAddressChecker.php b/lib/private/Http/Client/LocalAddressChecker.php index b233f34b19c..749a1a97c8a 100644 --- a/lib/private/Http/Client/LocalAddressChecker.php +++ b/lib/private/Http/Client/LocalAddressChecker.php @@ -36,13 +36,13 @@ class LocalAddressChecker { } public function ThrowIfLocalIp(string $ip) : void { - if ((bool)filter_var($ip, FILTER_VALIDATE_IP) && !filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { - $this->logger->warning("Host $ip was not connected to because it violates local access rules"); - throw new LocalServerException('Host violates local access rules'); - } - $localIps = ['100.100.100.200']; - if ((bool)filter_var($ip, FILTER_VALIDATE_IP) && in_array($ip, $localIps)) { + if ( + (bool)filter_var($ip, FILTER_VALIDATE_IP) && + ( + !filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) || + in_array($ip, $localIps, true) + )) { $this->logger->warning("Host $ip was not connected to because it violates local access rules"); throw new LocalServerException('Host violates local access rules'); }