aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKonrad Bucheli <kb@open.ch>2019-12-10 22:16:03 +0100
committerKonrad Bucheli <kb@open.ch>2019-12-10 22:47:20 +0100
commitf2d3e34c96ded153a095508f4dcd4fc76d9a9a8c (patch)
tree3cb03ab9743da029417b588358e9bdf9d0a603e3 /lib
parentda571c915eb5a47dacc88ec2210a714c746eec3b (diff)
downloadnextcloud-server-f2d3e34c96ded153a095508f4dcd4fc76d9a9a8c.tar.gz
nextcloud-server-f2d3e34c96ded153a095508f4dcd4fc76d9a9a8c.zip
handle IPv6 addresses with an explict incoming interface at the end (e.g fe80::ae2d:d1e7:fe1e:9a8d%enp2s0)
Signed-off-by: Konrad Bucheli <konrad.bucheli@gmx.ch> Signed-off-by: Konrad Bucheli <kb@open.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Security/Normalizer/IpAddress.php4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php
index 3bac6d8b103..8fb7b1003c4 100644
--- a/lib/private/Security/Normalizer/IpAddress.php
+++ b/lib/private/Security/Normalizer/IpAddress.php
@@ -75,6 +75,10 @@ class IpAddress {
if ($ip[0] === '[' && $ip[-1] === ']') { // If IP is with brackets, for example [::1]
$ip = substr($ip, 1, strlen($ip) - 2);
}
+ $pos = strpos($ip, '%'); // if there is an explicit interface added to the IP, e.g. fe80::ae2d:d1e7:fe1e:9a8d%enp2s0
+ if ($pos !== false) {
+ $ip = substr($ip, 0, $pos-1);
+ }
$binary = \inet_pton($ip);
for ($i = 128; $i > $maskBits; $i -= 8) {
$j = \intdiv($i, 8) - 1;