Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow URI as data for vcard PHOTO
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
  • Loading branch information
skjnldsv authored and MorrisJobke committed Jan 4, 2019
commit fa6c25708455d061da20178d021674ebb661c297
1 change: 1 addition & 0 deletions apps/dav/lib/CardDAV/ImageExportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response)

$response->setBody($file->getContent());
} catch (NotFoundException $e) {
var_dump($e);
$response->setStatus(404);
}

Expand Down
13 changes: 9 additions & 4 deletions apps/dav/lib/CardDAV/PhotoCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCP\Files\SimpleFS\ISimpleFolder;
use Sabre\CardDAV\Card;
use Sabre\VObject\Property\Binary;
use Sabre\VObject\Property\Uri;
use Sabre\VObject\Reader;

class PhotoCache {
Expand Down Expand Up @@ -193,19 +194,23 @@ private function getPhoto(Card $node) {
}

$photo = $vObject->PHOTO;
$type = $this->getType($photo);

$val = $photo->getValue();

// handle data URI. e.g PHOTO;VALUE=URI:data:image/jpeg;base64,/9j/4AAQSkZJRgABAQE
if ($photo->getValueType() === 'URI') {
$parsed = \Sabre\URI\parse($val);
//only allow data://

// only allow data://
if ($parsed['scheme'] !== 'data') {
return false;
}
if (substr_count($parsed['path'], ';') === 1) {
list($type,) = explode(';', $parsed['path']);
}
$val = file_get_contents($val);
} else {
// get type if binary data
$type = $this->getBinaryType($photo);
}

$allowedContentTypes = [
Expand Down Expand Up @@ -240,7 +245,7 @@ private function readCard($cardData) {
* @param Binary $photo
* @return string
*/
private function getType(Binary $photo) {
private function getBinaryType(Binary $photo) {
$params = $photo->parameters();
if (isset($params['TYPE']) || isset($params['MEDIATYPE'])) {
/** @var Parameter $typeParam */
Expand Down