From d59b3392abf021d0289b5b2ea1a67bc99e8d89da Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 21 Oct 2017 11:19:01 +0200 Subject: disallow users to create calendars with reserved names Signed-off-by: Georg Ehrke --- apps/dav/lib/CalDAV/CalendarHome.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'apps/dav/lib') diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php index c1988c7493e..3e645db459f 100644 --- a/apps/dav/lib/CalDAV/CalendarHome.php +++ b/apps/dav/lib/CalDAV/CalendarHome.php @@ -32,6 +32,8 @@ use Sabre\CalDAV\Schedule\Inbox; 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 { @@ -54,6 +56,19 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome { 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 */ -- cgit v1.2.3