From 588574d52680708246bd532a973d4f9e268db235 Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Sat, 1 Oct 2022 23:43:43 +0200 Subject: [PATCH] Disable sharing calendars via link when sharik via link is disabled This mod disallows sharing calendars via link when `shareapi_allow_links` is disabled. Related: https://github.com/nextcloud/calendar/issues/525 Related: https://github.com/nextcloud/calendar/issues/4399 Author-Change-Id: IB#1126264 Signed-off-by: Pawel Boguslawski --- apps/dav/lib/CalDAV/CalDavBackend.php | 9 +++++++++ apps/dav/lib/CalDAV/Publishing/PublishPlugin.php | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index b00a4f9d6ed73..4e5efd12e2b30 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2018 Georg Ehrke * @copyright Copyright (c) 2020, leith abdulla () + * @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ * * @author Chih-Hsuan Yen * @author Christoph Wurst @@ -516,6 +517,10 @@ private function getUserDisplayName($uid) { * @return array */ public function getPublicCalendars() { + // Sharing via link must be enabled. + if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) { + return array_values([]); + } $fields = array_column($this->propertyMap, 0); $fields[] = 'a.id'; $fields[] = 'a.uri'; @@ -574,6 +579,10 @@ public function getPublicCalendars() { * @throws NotFound */ public function getPublicCalendar($uri) { + // Sharing via link must be enabled. + if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) { + throw new NotFound('Node with name \'' . $uri . '\' could not be found'); + } $fields = array_column($this->propertyMap, 0); $fields[] = 'a.id'; $fields[] = 'a.uri'; diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php index aabf78da1aa8b..e0078fa1fefd6 100644 --- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php +++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php @@ -1,6 +1,7 @@ + * @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ * * @author Christoph Wurst * @author Georg Ehrke @@ -205,6 +206,11 @@ public function httpPost(RequestInterface $request, ResponseInterface $response) } } + // Sharing via link must be enabled. + if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no') { + return; + } + $node->setPublishStatus(true); // iCloud sends back the 202, so we will too.