]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix PROPPATCH requests to read-only shared calendars 4621/head
authorGeorg Ehrke <developer@georgehrke.com>
Mon, 1 May 2017 12:37:24 +0000 (14:37 +0200)
committerGeorg Ehrke <developer@georgehrke.com>
Mon, 8 May 2017 10:09:15 +0000 (12:09 +0200)
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
apps/dav/lib/CalDAV/Calendar.php
apps/dav/tests/unit/CalDAV/CalendarTest.php
apps/dav/tests/unit/CalDAV/PublicCalendarTest.php

index a216e4e078b3e1cc8a183e59a2a12bbf018f859a..9c56398b14c8e7af936dcc8b6b3dc82e6ba955f0 100644 (file)
@@ -145,11 +145,16 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
                        ];
                }
 
-               if ($this->isShared()) {
+               $acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl);
+
+               if (!$this->isShared()) {
                        return $acl;
                }
 
-               return $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl);
+               $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public'];
+               return array_filter($acl, function($rule) use ($allowedPrincipals) {
+                       return in_array($rule['principal'], $allowedPrincipals);
+               });
        }
 
        public function getChildACL() {
index 4ede886d31e5ca3f29cf29fdc8bac541be10cc53..cf295f01065192fbfb76c62edb833090fb784e3e 100644 (file)
@@ -246,6 +246,7 @@ class CalendarTest extends TestCase {
                        ]);
                $backend->expects($this->any())->method('getCalendarObject')
                        ->willReturn($calObject2)->with(666, 'event-2');
+               $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
 
                $calendarInfo = [
                        'principaluri' => 'user2',
@@ -333,6 +334,7 @@ EOD;
                        ]);
                $backend->expects($this->any())->method('getCalendarObject')
                        ->willReturn($calObject1)->with(666, 'event-1');
+               $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
 
                $calendarInfo = [
                        '{http://owncloud.org/ns}owner-principal' => $isShared ? 'user1' : 'user2',
index 6b2bf58d3924ef0f6d9c04b79fa00a02a4958bac..03cbf71d6ca670da6d7e80a04d453e76990a908c 100644 (file)
@@ -51,6 +51,7 @@ class PublicCalendarTest extends CalendarTest {
                        ]);
                $backend->expects($this->any())->method('getCalendarObject')
                        ->willReturn($calObject2)->with(666, 'event-2');
+               $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
 
                $calendarInfo = [
                        '{http://owncloud.org/ns}owner-principal' => 'user2',
@@ -135,6 +136,7 @@ EOD;
                        ]);
                $backend->expects($this->any())->method('getCalendarObject')
                        ->willReturn($calObject1)->with(666, 'event-1');
+               $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
 
                $calendarInfo = [
                        '{http://owncloud.org/ns}owner-principal' => 'user1',