diff options
author | Sebastian Krupinski <165827823+SebastianKrupinski@users.noreply.github.com> | 2024-10-02 09:04:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-02 09:04:21 -0400 |
commit | 2d004c3bc4b0cd96a6318a72c3a90e8706994106 (patch) | |
tree | 0ef4c3590eccb2d1d7c95a272ac50afd9427a9a6 /apps/dav | |
parent | 16d125c2209a5cf5dd2265ea95f6ed18c6bef6a8 (diff) | |
parent | a5eb38f277d98eac3957e48dc4a3f57a109c44f1 (diff) | |
download | nextcloud-server-2d004c3bc4b0cd96a6318a72c3a90e8706994106.tar.gz nextcloud-server-2d004c3bc4b0cd96a6318a72c3a90e8706994106.zip |
Merge pull request #48519 from nextcloud/bug/48518/ignore-invalid-dates
fix(dav): don't crash subscription on invalid calendar object
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php | 11 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php index 348a4e5ddbd..988898fc6d8 100644 --- a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php +++ b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php @@ -12,6 +12,7 @@ use OCA\DAV\CalDAV\CalDavBackend; use OCP\AppFramework\Utility\ITimeFactory; use Psr\Log\LoggerInterface; use Sabre\DAV\Exception\BadRequest; +use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\PropPatch; use Sabre\VObject\Component; use Sabre\VObject\DateTimeParser; @@ -101,7 +102,13 @@ class RefreshWebcalService { continue; } - $denormalized = $this->calDavBackend->getDenormalizedData($vObject->serialize()); + try { + $denormalized = $this->calDavBackend->getDenormalizedData($vObject->serialize()); + } catch (InvalidDataException|Forbidden $ex) { + $this->logger->warning('Unable to denormalize calendar object from subscription {subscriptionId}', ['exception' => $ex, 'subscriptionId' => $subscription['id'], 'source' => $subscription['source']]); + continue; + } + // Find all identical sets and remove them from the update if (isset($localData[$uid]) && $denormalized['etag'] === $localData[$uid]['etag']) { unset($localData[$uid]); @@ -127,7 +134,7 @@ class RefreshWebcalService { $objectUri = $this->getRandomCalendarObjectUri(); $this->calDavBackend->createCalendarObject($subscription['id'], $objectUri, $vObject->serialize(), CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION); } catch (NoInstancesException|BadRequest $ex) { - $this->logger->error('Unable to create calendar object from subscription {subscriptionId}', ['exception' => $ex, 'subscriptionId' => $subscription['id'], 'source' => $subscription['source']]); + $this->logger->warning('Unable to create calendar object from subscription {subscriptionId}', ['exception' => $ex, 'subscriptionId' => $subscription['id'], 'source' => $subscription['source']]); } } diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php index b9b05be4471..d65a99a15e0 100644 --- a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php @@ -252,7 +252,7 @@ class RefreshWebcalServiceTest extends TestCase { ->willThrowException($noInstanceException); $this->logger->expects(self::once()) - ->method('error') + ->method('warning') ->with('Unable to create calendar object from subscription {subscriptionId}', ['exception' => $noInstanceException, 'subscriptionId' => '42', 'source' => 'webcal://foo.bar/bla2']); $refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123'); @@ -302,7 +302,7 @@ class RefreshWebcalServiceTest extends TestCase { ->willThrowException($badRequestException); $this->logger->expects(self::once()) - ->method('error') + ->method('warning') ->with('Unable to create calendar object from subscription {subscriptionId}', ['exception' => $badRequestException, 'subscriptionId' => '42', 'source' => 'webcal://foo.bar/bla2']); $refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123'); |