]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(dav): don't crash subscription on invalid calendar object backport/48519/stable30 48529/head
authorescoand <escoand@users.noreply.github.com>
Wed, 25 Sep 2024 10:29:12 +0000 (12:29 +0200)
committerDaniel Kesselberg <mail@danielkesselberg.de>
Wed, 2 Oct 2024 13:53:50 +0000 (15:53 +0200)
Signed-off-by: escoand <escoand@users.noreply.github.com>
apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php
apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php

index 102571c8ef9efb9578526eeaf29d4eb5b8d02dd3..5a48ea8fa45ce7b830e65f306042d52b476dffc7 100644 (file)
@@ -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;
@@ -99,7 +100,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]);
@@ -125,7 +132,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']]);
                                }
                        }
 
index ed140fd76ff3d9bb1815a0b4086f1e8f58502e50..0ca57333b35883ec91b27e0f40eebf059d5090fd 100644 (file)
@@ -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');