Selaa lähdekoodia

Use new dependency to normalize IPs

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
tags/v26.0.0beta1
Côme Chilliet 1 vuosi sitten
vanhempi
commit
7ac688a2e5
No account linked to committer's email address
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 13
    0
      lib/private/Http/Client/LocalAddressChecker.php

+ 13
- 0
lib/private/Http/Client/LocalAddressChecker.php Näytä tiedosto

@@ -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

Loading…
Peruuta
Tallenna