Skip to content
Snippets Groups Projects
Unverified Commit 648c8df5 authored by Joas Schilling's avatar Joas Schilling Committed by Georg Ehrke
Browse files

Don't populate the PHOTO property when it's not an image

parent bb754cb3
No related branches found
No related tags found
No related merge requests found
......@@ -874,10 +874,33 @@ class CardDavBackend implements BackendInterface, SyncSupport {
private function readBlob($cardData) {
if (is_resource($cardData)) {
return stream_get_contents($cardData);
$cardData = stream_get_contents($cardData);
}
return $cardData;
$cardDataArray = explode("\r\n", $cardData);
$cardDataFiltered = [];
$removingPhoto = false;
foreach ($cardDataArray as $line) {
if (strpos($line, 'PHOTO:data:') === 0
&& strpos($line, 'PHOTO:data:image/') !== 0) {
// Filter out PHOTO data of non-images
$removingPhoto = true;
continue;
}
if ($removingPhoto) {
if (strpos($line, ' ') === 0) {
continue;
}
// No leading space means this is a new property
$removingPhoto = false;
}
$cardDataFiltered[] = $line;
}
return implode("\r\n", $cardDataFiltered);
}
/**
......
......@@ -62,7 +62,12 @@ class HasPhotoPlugin extends ServerPlugin {
if ($node instanceof Card) {
$propFind->handle($ns . 'has-photo', function () use ($node) {
$vcard = Reader::read($node->get());
return ($vcard instanceof VCard && $vcard->PHOTO);
return $vcard instanceof VCard
&& $vcard->PHOTO
// Either the PHOTO is a url (doesn't start with data:) or the mimetype has to start with image/
&& (strpos($vcard->PHOTO->getValue(), 'data:') !== 0
|| strpos($vcard->PHOTO->getValue(), 'data:image/') === 0)
;
});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment