From 45eefc221d4439c99fd2c8badfe93dc3af40f028 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 a147d785cc7..fd72b1886ba 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 @@ -512,6 +513,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @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'; @@ -570,6 +575,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @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 aabf78da1aa..e0078fa1fef 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 @@ class PublishPlugin extends ServerPlugin { } } + // 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.