diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php
index a07bbe9321..e80bffdb9d 100644
--- a/apps/dav/lib/CalDAV/Calendar.php
+++ b/apps/dav/lib/CalDAV/Calendar.php
@@ -139,6 +139,10 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
];
}
+ if (!$this->isShared()) {
+ return $acl;
+ }
+
if ($this->getOwner() !== parent::getOwner()) {
$acl[] = [
'privilege' => '{DAV:}read',
@@ -168,14 +172,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
}
$acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl);
-
- if (!$this->isShared()) {
- return $acl;
- }
-
$allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public'];
return array_filter($acl, function($rule) use ($allowedPrincipals) {
- return in_array($rule['principal'], $allowedPrincipals);
+ return \in_array($rule['principal'], $allowedPrincipals, true);
});
}
diff --git a/apps/dav/lib/CardDAV/AddressBook.php b/apps/dav/lib/CardDAV/AddressBook.php
index 7120231987..30ce0a3253 100644
--- a/apps/dav/lib/CardDAV/AddressBook.php
+++ b/apps/dav/lib/CardDAV/AddressBook.php
@@ -105,12 +105,17 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
'privilege' => '{DAV:}read',
'principal' => $this->getOwner(),
'protected' => true,
- ]];
- $acl[] = [
+ ],[
'privilege' => '{DAV:}write',
'principal' => $this->getOwner(),
'protected' => true,
- ];
+ ]
+ ];
+
+ if (!$this->isShared()) {
+ return $acl;
+ }
+
if ($this->getOwner() !== parent::getOwner()) {
$acl[] = [
'privilege' => '{DAV:}read',
@@ -133,11 +138,11 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
];
}
- if ($this->isShared()) {
- return $acl;
- }
-
- return $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl);
+ $acl = $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl);
+ $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/system'];
+ return array_filter($acl, function($rule) use ($allowedPrincipals) {
+ return \in_array($rule['principal'], $allowedPrincipals, true);
+ });
}
public function getChildACL() {
diff --git a/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml b/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml
index 334fa561ae..6c15a79322 100644
--- a/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml
+++ b/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml
@@ -73,7 +73,7 @@
Shared calendar exists
PROPFIND
- $calendarhome1:/shared/
+ $calendarhome2:/shared_shared_by_user01/
Depth
0
@@ -193,7 +193,7 @@
Sharee creates event
PUT
- $calendarhome1:/shared/1.ics
+ $calendarhome2:/shared_shared_by_user01/1.ics
text/calendar; charset=utf-8
Resource/CalDAV/sharing/calendars/read-write/5.ics
@@ -235,7 +235,7 @@
Sharee sees changed event
GET
- $calendarhome1:/shared/1.ics
+ $calendarhome2:/shared_shared_by_user01/1.ics
calendarDataMatch
@@ -263,7 +263,7 @@
Sharee sees new event
GET
- $calendarhome1:/shared/2.ics
+ $calendarhome2:/shared_shared_by_user01/2.ics
calendarDataMatch
@@ -277,7 +277,7 @@
Sharee changes event
PUT
- $calendarhome1:/shared/2.ics
+ $calendarhome2:/shared_shared_by_user01/2.ics
text/calendar; charset=utf-8
Resource/CalDAV/sharing/calendars/read-write/8.ics
diff --git a/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml b/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml
index 84ee626501..99e40f5c68 100644
--- a/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml
+++ b/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml
@@ -17,7 +17,7 @@
POST invitation
POST
- $addressbookpath1:
+ $addressbookhome1:/addressbook/
text/xml; charset=utf-8
Resource/CardDAV/sharing/read-write/1.xml
@@ -31,7 +31,7 @@
Shared addressbook exists
PROPFIND
- $addressbookpath1:/
+ $addressbookhome2:/addressbook_shared_by_user01/
Depth
0
@@ -62,7 +62,7 @@
- Shared calendar exists Depth:1
+ Shared addressbook exists Depth:1
PROPFIND
$addressbookhome2:/
@@ -100,7 +100,7 @@
- Original calendar unchanged
+ Original addressbook unchanged
PROPFIND
$addressbookpath1:
@@ -126,7 +126,7 @@
Sharee creates contact
PUT
- $addressbookpath1:/1.vcf
+ $addressbookhome2:/addressbook_shared_by_user01/1.vcf
text/vcard; charset=utf-8
Resource/CardDAV/sharing/read-write/6.vcf
@@ -171,7 +171,7 @@
Sharee sees changed contact
GET
- $addressbookpath1:/1.vcf
+ $addressbookhome2:/addressbook_shared_by_user01/1.vcf
addressDataMatch
@@ -183,7 +183,7 @@
- Sharer creates event
+ Sharer creates contact
PUT
$addressbookpath1:/2.vcf
@@ -197,10 +197,10 @@
- Sharee sees new event
+ Sharee sees new contact
GET
- $addressbookpath1:/2.vcf
+ $addressbookhome2:/addressbook_shared_by_user01/2.vcf
addressDataMatch
@@ -211,10 +211,10 @@
- Sharee changes event
+ Sharee changes contact
PUT
- $addressbookpath1:/2.vcf
+ $addressbookhome2:/addressbook_shared_by_user01/2.vcf
text/vcard; charset=utf-8
Resource/CardDAV/sharing/read-write/9.vcf
@@ -225,7 +225,7 @@
- Sharer sees changed event
+ Sharer sees changed contact
GET
$addressbookpath1:/2.vcf
@@ -281,7 +281,7 @@
- Shared calendar no longer exists Depth:1
+ Shared addressbook no longer exists Depth:1
PROPFIND
$addressbookhome2: