From 96e650973662fed288bae953218f18cc90b9ca96 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 21 Oct 2017 11:19:01 +0200 Subject: [PATCH] disallow users to create calendars with reserved names --- apps/dav/lib/CalDAV/CalendarHome.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php index b26e95befe6d9..43fa5f81fd6df 100644 --- a/apps/dav/lib/CalDAV/CalendarHome.php +++ b/apps/dav/lib/CalDAV/CalendarHome.php @@ -30,6 +30,8 @@ use Sabre\CalDAV\Schedule\Outbox; use Sabre\CalDAV\Subscriptions\Subscription; use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\Exception\MethodNotAllowed; +use Sabre\DAV\MkCol; class CalendarHome extends \Sabre\CalDAV\CalendarHome { @@ -52,6 +54,19 @@ public function getCalDAVBackend() { return $this->caldavBackend; } + /** + * @inheritdoc + */ + function createExtendedCollection($name, MkCol $mkCol) { + $reservedNames = [BirthdayService::BIRTHDAY_CALENDAR_URI]; + + if (in_array($name, $reservedNames)) { + throw new MethodNotAllowed('The resource you tried to create has a reserved name'); + } + + parent::createExtendedCollection($name, $mkCol); + } + /** * @inheritdoc */