ソースを参照

Use new dependency to normalize IPs

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
tags/v26.0.0beta1
Côme Chilliet 1年前
コミット
7ac688a2e5
コミッターのメールアドレスに関連付けられたアカウントが存在しません
1個のファイルの変更13行の追加0行の削除
  1. 13
    0
      lib/private/Http/Client/LocalAddressChecker.php

+ 13
- 0
lib/private/Http/Client/LocalAddressChecker.php ファイルの表示

*/ */
namespace OC\Http\Client; namespace OC\Http\Client;


use IPLib\Factory;
use IPLib\ParseStringFlag;
use OCP\Http\Client\LocalServerException; use OCP\Http\Client\LocalServerException;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\IpUtils; use Symfony\Component\HttpFoundation\IpUtils;
} }


public function ThrowIfLocalIp(string $ip) : void { 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 = [ $localRanges = [
'100.64.0.0/10', // See RFC 6598 '100.64.0.0/10', // See RFC 6598
'192.0.0.0/24', // See RFC 6890 '192.0.0.0/24', // See RFC 6890

読み込み中…
キャンセル
保存