]> source.dussan.org Git - nextcloud-server.git/commitdiff
Support more IPv6 addresses in the RefreshWebcalJob 18368/head
authorGeorg Ehrke <developer@georgehrke.com>
Thu, 12 Dec 2019 09:05:36 +0000 (10:05 +0100)
committerBackportbot <backportbot-noreply@rullzer.com>
Thu, 12 Dec 2019 10:07:43 +0000 (10:07 +0000)
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
apps/dav/lib/BackgroundJob/RefreshWebcalJob.php
apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php

index e99cd7038f653096ed5c686a7e9450bc0bcc70ae..4c1f12f63ea197d5927c1cdbafe846d9e959822d 100644 (file)
@@ -247,6 +247,17 @@ class RefreshWebcalJob extends Job {
                                $this->logger->warning("Subscription $subscriptionId was not refreshed because it violates local access rules");
                                return null;
                        }
+
+                       // Also check for IPv6 IPv4 nesting, because that's not covered by filter_var
+                       if ((bool)filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($host, '.') > 0) {
+                               $delimiter = strrpos($host, ':'); // Get last colon
+                               $ipv4Address = substr($host, $delimiter + 1);
+
+                               if (!filter_var($ipv4Address, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
+                                       $this->logger->warning("Subscription $subscriptionId was not refreshed because it violates local access rules");
+                                       return null;
+                               }
+                       }
                }
 
                try {
index 8e24fb1f638910197dcf53fc7b30dc23d5371a3b..3490efa92f86bc64f2444fc12a90fdb9ad2961ac 100644 (file)
@@ -239,6 +239,8 @@ class RefreshWebcalJobTest extends TestCase {
                        ['172.16.42.1'],
                        ['[fdf8:f53b:82e4::53]/secret.ics'],
                        ['[fe80::200:5aee:feaa:20a2]/secret.ics'],
+                       ['[0:0:0:0:0:0:10.0.0.1]/secret.ics'],
+                       ['[0:0:0:0:0:ffff:127.0.0.0]/secret.ics'],
                        ['10.0.0.1'],
                        ['another-host.local'],
                        ['service.localhost'],