From 3a133b151fe790c3e4a227f17a75a37b44b8e50a Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 23 Apr 2018 13:48:39 +0200 Subject: 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 02808ab5662..a07bbe93218 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 a034f8b9426..71202319874 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 06fb10f7e2c..250d67aafd1 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -325,6 +325,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 141c54899ad..8412ccc6010 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); + } } } -- cgit v1.2.3