Add check for vCard uid

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-11-03 19:03:32 +01:00 committed by Joas Schilling
parent cba3883410
commit b6d8c5ff2f
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 13 additions and 0 deletions

View File

@ -611,6 +611,19 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$etag = md5($cardData);
$uid = $this->getUID($cardData);
$q = $this->db->getQueryBuilder();
$q->select('uid')
->from('cards')
->where($q->expr()->eq('addressbookid', $q->createNamedParameter($addressBookId)))
->andWhere($q->expr()->eq('uid', $q->createNamedParameter($uid)))
->setMaxResults(1);
$result = $q->execute();
$count = (bool) $result->fetchColumn();
$result->closeCursor();
if ($count) {
throw new \Sabre\DAV\Exception\BadRequest('VCard object with uid already exists in this addressbook collection.');
}
$query = $this->db->getQueryBuilder();
$query->insert('cards')
->values([