diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-09-20 12:34:04 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-09-22 16:39:34 +0200 |
commit | 515e05cf16f7d2407388d0a3120d019820f08fe4 (patch) | |
tree | 5932fe6b7db86d30c4ca60d65700d386f51772ef /lib/private/Http | |
parent | 060230eec7b962a2854bd2a79ffae668049d437c (diff) | |
download | nextcloud-server-515e05cf16f7d2407388d0a3120d019820f08fe4.tar.gz nextcloud-server-515e05cf16f7d2407388d0a3120d019820f08fe4.zip |
Use new dependency to normalize IPs
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Http')
-rw-r--r-- | lib/private/Http/Client/LocalAddressChecker.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/Http/Client/LocalAddressChecker.php b/lib/private/Http/Client/LocalAddressChecker.php index b0de54b430f..274186d0a5a 100644 --- a/lib/private/Http/Client/LocalAddressChecker.php +++ b/lib/private/Http/Client/LocalAddressChecker.php @@ -25,6 +25,8 @@ declare(strict_types=1); */ namespace OC\Http\Client; +use IPLib\Factory; +use IPLib\ParseStringFlag; use OCP\Http\Client\LocalServerException; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\IpUtils; @@ -37,6 +39,17 @@ class LocalAddressChecker { } public function ThrowIfLocalIp(string $ip) : void { + $parsedIp = Factory::parseAddressString( + $ip, + ParseStringFlag::IPV4_MAYBE_NON_DECIMAL | ParseStringFlag::IPV4ADDRESS_MAYBE_NON_QUAD_DOTTED + ); + if ($parsedIp === null) { + /* Not an IP */ + return; + } + /* Replace by normalized form */ + $ip = (string)$parsedIp; + $localRanges = [ '100.64.0.0/10', // See RFC 6598 '192.0.0.0/24', // See RFC 6890 |