From 9f3d07e339e728e0bd57d3bfcfdfab498cab5198 Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Wed, 17 Jul 2024 15:26:05 -0400 Subject: [PATCH] fix(caldav): Throw 403 Forbidden Error instead of 500 Internal Server Error Signed-off-by: SebastianKrupinski --- apps/dav/lib/CalDAV/CalDavBackend.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 58deffc1536eb..79e1025c5ee49 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -98,6 +98,7 @@ use Sabre\VObject\Property; use Sabre\VObject\Reader; use Sabre\VObject\Recur\EventIterator; +use Sabre\VObject\Recur\NoInstancesException; use function array_column; use function array_map; use function array_merge; @@ -3020,7 +3021,15 @@ public function getDenormalizedData(string $calendarData): array { $lastOccurrence = $firstOccurrence; } } else { - $it = new EventIterator($vEvents); + try { + $it = new EventIterator($vEvents); + } catch (NoInstancesException $e) { + $this->logger->debug('Caught no instance exception for calendar data. This usually indicates invalid calendar data.', [ + 'app' => 'dav', + 'exception' => $e, + ]); + throw new Forbidden($e->getMessage()); + } $maxDate = new DateTime(self::MAX_DATE); $firstOccurrence = $it->getDtStart()->getTimestamp(); if ($it->isInfinite()) {