Merge pull request #18352 from nextcloud/backport/18341/stable17

[stable17] handle IPv6 addresses with an explict incoming interface at the end
This commit is contained in:
Roeland Jago Douma 2019-12-11 15:42:18 +01:00 committed by GitHub
commit a34b05cb27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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