Skip to content

Commit

Permalink
Merge pull request #20431 from owncloud/carddav-enforce-displayname
Browse files Browse the repository at this point in the history
When creating addressbooks, make sure the displayname is set
  • Loading branch information
DeepDiver1975 committed Nov 10, 2015
2 parents cc43213 + 06d1685 commit f77c6db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/dav/lib/carddav/carddavbackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
* @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 = [
Expand All @@ -160,6 +160,12 @@ function createAddressBook($principalUri, $url, array $properties) {

}

// 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([
Expand Down
1 change: 1 addition & 0 deletions apps/dav/tests/unit/carddav/carddavbackendtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function testAddressBookOperations() {

$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([
Expand Down

0 comments on commit f77c6db

Please sign in to comment.