Skip to content

Commit

Permalink
Merge pull request #18366 from nextcloud/backport/18364/stable17
Browse files Browse the repository at this point in the history
[stable17] Support more IPv6 addresses in the RefreshWebcalJob
  • Loading branch information
rullzer authored Dec 12, 2019
2 parents 387d216 + f2551e5 commit feaf758
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/dav/lib/BackgroundJob/RefreshWebcalJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ private function queryWebcalFeed(array $subscription, array &$mutations) {
$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 {
Expand Down
2 changes: 2 additions & 0 deletions apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ public function runLocalURLDataProvider():array {
['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'],
Expand Down

0 comments on commit feaf758

Please sign in to comment.