diff options
author | Konrad Bucheli <kb@open.ch> | 2019-12-10 22:16:03 +0100 |
---|---|---|
committer | Backportbot <backportbot-noreply@rullzer.com> | 2019-12-11 10:34:21 +0000 |
commit | f914b98860291cc7f3aa40738ee3c3a7567e2ab3 (patch) | |
tree | 8ebf8ebbf1b2d26d9ed49a01f0a674a4444e0582 /lib/private | |
parent | 624302d99a75af84fb7d5f71df89335dce57659f (diff) | |
download | nextcloud-server-f914b98860291cc7f3aa40738ee3c3a7567e2ab3.tar.gz nextcloud-server-f914b98860291cc7f3aa40738ee3c3a7567e2ab3.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/private')
-rw-r--r-- | lib/private/Security/Normalizer/IpAddress.php | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php index 4edf83eca5e..c470b08aa7c 100644 --- a/lib/private/Security/Normalizer/IpAddress.php +++ b/lib/private/Security/Normalizer/IpAddress.php @@ -71,6 +71,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; |