Allow URI as data for vcard PHOTO

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-12-17 12:45:07 +01:00 committed by Morris Jobke
parent 14fcc64c49
commit fa6c257084
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
2 changed files with 10 additions and 4 deletions

View File

@ -108,6 +108,7 @@ class ImageExportPlugin extends ServerPlugin {
$response->setBody($file->getContent());
} catch (NotFoundException $e) {
var_dump($e);
$response->setStatus(404);
}

View File

@ -30,6 +30,7 @@ use OCP\Files\SimpleFS\ISimpleFile;
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 {
@ -193,12 +194,13 @@ class PhotoCache {
}
$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;
}
@ -206,6 +208,9 @@ class PhotoCache {
list($type,) = explode(';', $parsed['path']);
}
$val = file_get_contents($val);
} else {
// get type if binary data
$type = $this->getBinaryType($photo);
}
$allowedContentTypes = [
@ -240,7 +245,7 @@ class PhotoCache {
* @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 */