diff options
author | Daniel <mail@danielkesselberg.de> | 2024-10-02 18:29:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-02 18:29:13 +0200 |
commit | 3846e0aafc758fe41165e38a833f9f6eb6784fab (patch) | |
tree | 07f0e6c7e56e3f5393ee97fc5d84f69817155ba5 /apps | |
parent | d0f14e5bdb075450229e51915a0130e1f6b88c17 (diff) | |
parent | 48eec1fd3564f59fdd69a244a1ae29b175b13295 (diff) | |
download | nextcloud-server-3846e0aafc758fe41165e38a833f9f6eb6784fab.tar.gz nextcloud-server-3846e0aafc758fe41165e38a833f9f6eb6784fab.zip |
Merge pull request #48529 from nextcloud/backport/48519/stable30
[stable30] fix(dav): don't crash subscription on invalid calendar object
Diffstat (limited to 'apps')
-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 8ab3ecc202a..14c72285f67 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; @@ -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']]); } } diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php index ed140fd76ff..0ca57333b35 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'); |