summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-11-10 14:32:39 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-11-10 14:32:39 +0100
commitf77c6dbbed34fc1dcaaa3d35c7a9ecc499ce3e36 (patch)
tree6fb6485934da6bf3144a7515073a85c26ef2a487
parentcc4321317e5c1e3303b43ff1ad0a149324af7726 (diff)
parent06d1685e75f88a2423c3bcdc71b79c95c806347c (diff)
downloadnextcloud-server-f77c6dbbed34fc1dcaaa3d35c7a9ecc499ce3e36.tar.gz
nextcloud-server-f77c6dbbed34fc1dcaaa3d35c7a9ecc499ce3e36.zip
Merge pull request #20431 from owncloud/carddav-enforce-displayname
When creating addressbooks, make sure the displayname is set
-rw-r--r--apps/dav/lib/carddav/carddavbackend.php8
-rw-r--r--apps/dav/tests/unit/carddav/carddavbackendtest.php1
2 files changed, 8 insertions, 1 deletions
diff --git a/apps/dav/lib/carddav/carddavbackend.php b/apps/dav/lib/carddav/carddavbackend.php
index 7b16262a680..b2597baedc6 100644
--- a/apps/dav/lib/carddav/carddavbackend.php
+++ b/apps/dav/lib/carddav/carddavbackend.php
@@ -134,7 +134,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* @param string $principalUri
* @param string $url Just the 'basename' of the url.
* @param array $properties
- * @return void
+ * @throws BadRequest
*/
function createAddressBook($principalUri, $url, array $properties) {
$values = [
@@ -160,6 +160,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
}
+ // Fallback to make sure the displayname is set. Some clients may refuse
+ // to work with addressbooks not having a displayname.
+ if(is_null($values['displayname'])) {
+ $values['displayname'] = $url;
+ }
+
$query = $this->db->getQueryBuilder();
$query->insert('addressbooks')
->values([
diff --git a/apps/dav/tests/unit/carddav/carddavbackendtest.php b/apps/dav/tests/unit/carddav/carddavbackendtest.php
index f7456e9634c..79ef36d8097 100644
--- a/apps/dav/tests/unit/carddav/carddavbackendtest.php
+++ b/apps/dav/tests/unit/carddav/carddavbackendtest.php
@@ -60,6 +60,7 @@ class CardDavBackendTest extends TestCase {
$books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
$this->assertEquals(1, count($books));
+ $this->assertEquals('Example', $books[0]['{DAV:}displayname']);
// update it's display name
$patch = new PropPatch([