aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2021-12-14 14:50:31 +0100
committerGitHub <noreply@github.com>2021-12-14 14:50:31 +0100
commit5613ff365b020b34774c717ff71483fc84e494fd (patch)
tree357ed6cf93f229ce4d65f0fbc50c785899f2b317 /apps
parent069fe1c12e817d277a8458b533607ac34a40433f (diff)
parentb005846d1f075f77f1e439950e581428d947231c (diff)
downloadnextcloud-server-5613ff365b020b34774c717ff71483fc84e494fd.tar.gz
nextcloud-server-5613ff365b020b34774c717ff71483fc84e494fd.zip
Merge pull request #30048 from nextcloud/fix/caldav-search-time-range-recurrence
Carefully filter out non matching time ranges for CalDAV search
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 1c26ee2eb8a..fa6e6a7ecbb 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -100,7 +100,9 @@ use function array_merge;
use function array_values;
use function explode;
use function is_array;
+use function is_resource;
use function pathinfo;
+use function rewind;
use function sprintf;
use function str_replace;
use function strtolower;
@@ -1915,7 +1917,39 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
$result = $outerQuery->executeQuery();
- $calendarObjects = $result->fetchAll();
+ $calendarObjects = array_filter($result->fetchAll(), function (array $row) use ($options) {
+ $start = $options['timerange']['start'] ?? null;
+ $end = $options['timerange']['end'] ?? null;
+
+ if ($start === null || !($start instanceof DateTimeInterface) || $end === null || !($end instanceof DateTimeInterface)) {
+ // No filter required
+ return true;
+ }
+
+ $isValid = $this->validateFilterForObject($row, [
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => 'VEVENT',
+ 'comp-filters' => [],
+ 'prop-filters' => [],
+ 'is-not-defined' => false,
+ 'time-range' => [
+ 'start' => $start,
+ 'end' => $end,
+ ],
+ ],
+ ],
+ 'prop-filters' => [],
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ ]);
+ if (is_resource($row['calendardata'])) {
+ // Put the stream back to the beginning so it can be read another time
+ rewind($row['calendardata']);
+ }
+ return $isValid;
+ });
$result->closeCursor();
return array_map(function ($o) {