Skip to content

Commit feaf758

Browse files
authored
Merge pull request #18366 from nextcloud/backport/18364/stable17
[stable17] Support more IPv6 addresses in the RefreshWebcalJob
2 parents 387d216 + f2551e5 commit feaf758

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

apps/dav/lib/BackgroundJob/RefreshWebcalJob.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ private function queryWebcalFeed(array $subscription, array &$mutations) {
247247
$this->logger->warning("Subscription $subscriptionId was not refreshed because it violates local access rules");
248248
return null;
249249
}
250+
251+
// Also check for IPv6 IPv4 nesting, because that's not covered by filter_var
252+
if ((bool)filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($host, '.') > 0) {
253+
$delimiter = strrpos($host, ':'); // Get last colon
254+
$ipv4Address = substr($host, $delimiter + 1);
255+
256+
if (!filter_var($ipv4Address, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
257+
$this->logger->warning("Subscription $subscriptionId was not refreshed because it violates local access rules");
258+
return null;
259+
}
260+
}
250261
}
251262

252263
try {

apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ public function runLocalURLDataProvider():array {
239239
['172.16.42.1'],
240240
['[fdf8:f53b:82e4::53]/secret.ics'],
241241
['[fe80::200:5aee:feaa:20a2]/secret.ics'],
242+
['[0:0:0:0:0:0:10.0.0.1]/secret.ics'],
243+
['[0:0:0:0:0:ffff:127.0.0.0]/secret.ics'],
242244
['10.0.0.1'],
243245
['another-host.local'],
244246
['service.localhost'],

0 commit comments

Comments
 (0)