From 240006bdf517df0a72d52efb285fdf9cf8b58d35 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 23 Apr 2018 13:48:39 +0200 Subject: [PATCH] When sharing calendars and addressbooks the principal has to be verified to be valid https://github.com/owncloud/core/pull/30149/commits/d3fb8fcdd3a6b00bde0c3c9eb4039876e7fc1967 Signed-off-by: Roeland Jago Douma --- apps/dav/lib/CalDAV/Calendar.php | 2 +- apps/dav/lib/CardDAV/AddressBook.php | 2 +- apps/dav/lib/Connector/Sabre/Principal.php | 7 +++++++ apps/dav/lib/DAV/Sharing/Backend.php | 12 +++++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php index 02808ab566..a07bbe9321 100644 --- a/apps/dav/lib/CalDAV/Calendar.php +++ b/apps/dav/lib/CalDAV/Calendar.php @@ -203,7 +203,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { } $this->caldavBackend->updateShares($this, [], [ - 'href' => $principal + $principal ]); return; } diff --git a/apps/dav/lib/CardDAV/AddressBook.php b/apps/dav/lib/CardDAV/AddressBook.php index a034f8b942..7120231987 100644 --- a/apps/dav/lib/CardDAV/AddressBook.php +++ b/apps/dav/lib/CardDAV/AddressBook.php @@ -181,7 +181,7 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable { } $this->carddavBackend->updateShares($this, [], [ - 'href' => $principal + $principal ]); return; } diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index b2f57cf715..b94b093ab5 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -324,6 +324,13 @@ class Principal implements BackendInterface { return $this->principalPrefix . '/' . $user->getUID(); } } + if (substr($uri, 0, 10) === 'principal:') { + $principal = substr($uri, 10); + $principal = $this->getPrincipalByPath($principal); + if ($principal !== null) { + return $principal['uri']; + } + } return null; } diff --git a/apps/dav/lib/DAV/Sharing/Backend.php b/apps/dav/lib/DAV/Sharing/Backend.php index 87c094c6d6..433d9db9c0 100644 --- a/apps/dav/lib/DAV/Sharing/Backend.php +++ b/apps/dav/lib/DAV/Sharing/Backend.php @@ -67,12 +67,18 @@ class Backend { * @param string[] $add * @param string[] $remove */ - public function updateShares($shareable, $add, $remove) { + public function updateShares(IShareable $shareable, array $add, array $remove) { foreach($add as $element) { - $this->shareWith($shareable, $element); + $principal = $this->principalBackend->findByUri($element['href'], ''); + if ($principal !== '') { + $this->shareWith($shareable, $element); + } } foreach($remove as $element) { - $this->unshare($shareable, $element); + $principal = $this->principalBackend->findByUri($element, ''); + if ($principal !== '') { + $this->unshare($shareable, $element); + } } }