diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-11-06 09:17:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 09:17:52 +0100 |
commit | 3c4290631bb2d51440fd4332335fcba2a2aa9c98 (patch) | |
tree | cadcc5c0da8d4b41b41061522032fc15daaa2ed6 /lib | |
parent | 452e4be4f5e27d76f3cb52b9016c0dbbd989841a (diff) | |
parent | e885e4f13dde99c56ee84106205d348fb399646e (diff) | |
download | nextcloud-server-3c4290631bb2d51440fd4332335fcba2a2aa9c98.tar.gz nextcloud-server-3c4290631bb2d51440fd4332335fcba2a2aa9c98.zip |
Merge pull request #49039 from nextcloud/jtr/fix-ipv6-zone-ids-link-local
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Net/IpAddressClassifier.php | 2 | ||||
-rw-r--r-- | lib/private/Security/Ip/Address.php | 5 | ||||
-rw-r--r-- | lib/private/Security/Ip/Range.php | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/lib/private/Net/IpAddressClassifier.php b/lib/private/Net/IpAddressClassifier.php index 5f41f4a086a..b73d41fd79b 100644 --- a/lib/private/Net/IpAddressClassifier.php +++ b/lib/private/Net/IpAddressClassifier.php @@ -34,7 +34,7 @@ class IpAddressClassifier { public function isLocalAddress(string $ip): bool { $parsedIp = Factory::parseAddressString( $ip, - ParseStringFlag::IPV4_MAYBE_NON_DECIMAL | ParseStringFlag::IPV4ADDRESS_MAYBE_NON_QUAD_DOTTED + ParseStringFlag::IPV4_MAYBE_NON_DECIMAL | ParseStringFlag::IPV4ADDRESS_MAYBE_NON_QUAD_DOTTED | ParseStringFlag::MAY_INCLUDE_ZONEID ); if ($parsedIp === null) { /* Not an IP */ diff --git a/lib/private/Security/Ip/Address.php b/lib/private/Security/Ip/Address.php index e0bb906e82d..0e94ec2d9ea 100644 --- a/lib/private/Security/Ip/Address.php +++ b/lib/private/Security/Ip/Address.php @@ -11,6 +11,7 @@ namespace OC\Security\Ip; use InvalidArgumentException; use IPLib\Address\AddressInterface; use IPLib\Factory; +use IPLib\ParseStringFlag; use OCP\Security\Ip\IAddress; use OCP\Security\Ip\IRange; @@ -21,7 +22,7 @@ class Address implements IAddress { private readonly AddressInterface $ip; public function __construct(string $ip) { - $ip = Factory::parseAddressString($ip); + $ip = Factory::parseAddressString($ip, ParseStringFlag::MAY_INCLUDE_ZONEID); if ($ip === null) { throw new InvalidArgumentException('Given IP address can’t be parsed'); } @@ -29,7 +30,7 @@ class Address implements IAddress { } public static function isValid(string $ip): bool { - return Factory::parseAddressString($ip) !== null; + return Factory::parseAddressString($ip, ParseStringFlag::MAY_INCLUDE_ZONEID) !== null; } public function matches(IRange ... $ranges): bool { diff --git a/lib/private/Security/Ip/Range.php b/lib/private/Security/Ip/Range.php index 39c03677f81..e32b7a5abc0 100644 --- a/lib/private/Security/Ip/Range.php +++ b/lib/private/Security/Ip/Range.php @@ -10,6 +10,7 @@ namespace OC\Security\Ip; use InvalidArgumentException; use IPLib\Factory; +use IPLib\ParseStringFlag; use IPLib\Range\RangeInterface; use OCP\Security\Ip\IAddress; use OCP\Security\Ip\IRange; @@ -30,7 +31,7 @@ class Range implements IRange { } public function contains(IAddress $address): bool { - return $this->range->contains(Factory::parseAddressString((string)$address)); + return $this->range->contains(Factory::parseAddressString((string)$address, ParseStringFlag::MAY_INCLUDE_ZONEID)); } public function __toString(): string { |