]> source.dussan.org Git - nextcloud-server.git/commitdiff
urldecode group principals in Cal- and CardDAV backend 5299/head
authorGeorg Ehrke <developer@georgehrke.com>
Thu, 8 Jun 2017 07:08:24 +0000 (09:08 +0200)
committerGeorg Ehrke <developer@georgehrke.com>
Mon, 12 Jun 2017 19:02:21 +0000 (21:02 +0200)
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
apps/dav/lib/CalDAV/CalDavBackend.php
apps/dav/lib/CardDAV/CardDavBackend.php
apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php
apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
apps/dav/tests/unit/CardDAV/CardDavBackendTest.php

index ef3df8de83ec007d2ae4bc52b631ff201cdf98ef..7fe18cd8656ee52912c8ea34e51c624b4adca22b 100644 (file)
@@ -276,6 +276,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
 
                // query for shared calendars
                $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
+               $principals = array_map(function($principal) {
+                       return urldecode($principal);
+               }, $principals);
                $principals[]= $principalUri;
 
                $fields = array_values($this->propertyMap);
index 983220c6ba0076a275d78893c8637141be1478ca..5742f97b701c5b2c019c58f38c170bec48fa0490 100644 (file)
@@ -162,6 +162,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
 
                // query for shared calendars
                $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
+               $principals = array_map(function($principal) {
+                       return urldecode($principal);
+               }, $principals);
                $principals[]= $principalUri;
 
                $query = $this->db->getQueryBuilder();
index bc161b00d91b1f3f01b87023710c981fb9ba1a6c..a7bf4432c6490b072424eea7e44c70452d529fb0 100644 (file)
@@ -91,6 +91,9 @@ abstract class AbstractCalDavBackendTest extends TestCase {
                if (is_null($this->backend)) {
                        return;
                }
+               $this->principal->expects($this->any())->method('getGroupMembership')
+                       ->withAnyParameters()
+                       ->willReturn([self::UNIT_TEST_GROUP, self::UNIT_TEST_GROUP2]);
                $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
                foreach ($calendars as $calendar) {
                        $this->dispatcher->expects($this->at(0))
index 7c424fd0dd1cdcd55508299295b2d8b3c1554fc5..eb9f9cd10d7db66823246b244da777134e71b468 100644 (file)
@@ -46,6 +46,10 @@ class PublicCalendarRootTest extends TestCase {
                $this->random = \OC::$server->getSecureRandom();
                $dispatcher = $this->createMock(EventDispatcherInterface::class);
 
+               $this->principal->expects($this->any())->method('getGroupMembership')
+                       ->withAnyParameters()
+                       ->willReturn([]);
+
                $this->backend = new CalDavBackend(
                        $db,
                        $this->principal,
@@ -66,6 +70,9 @@ class PublicCalendarRootTest extends TestCase {
                if (is_null($this->backend)) {
                        return;
                }
+               $this->principal->expects($this->any())->method('getGroupMembership')
+                       ->withAnyParameters()
+                       ->willReturn([]);
                $books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
                foreach ($books as $book) {
                        $this->backend->deleteCalendar($book['id']);
index f3a271a2db29892c792fa2b00e155bdffa9a498a..8ca7e8a33b1fc8e4d7bd91454e04692d316a7563 100644 (file)
@@ -113,6 +113,10 @@ class CardDavBackendTest extends TestCase {
                if (is_null($this->backend)) {
                        return;
                }
+
+               $this->principal->method('getGroupMembership')
+                       ->withAnyParameters()
+                       ->willReturn([self::UNIT_TEST_GROUP]);
                $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
                foreach ($books as $book) {
                        $this->backend->deleteAddressBook($book['id']);