Allow URI as data for vcard PHOTO
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
a5e77bc130
commit
d4652bbe8f
|
@ -108,6 +108,7 @@ class ImageExportPlugin extends ServerPlugin {
|
||||||
|
|
||||||
$response->setBody($file->getContent());
|
$response->setBody($file->getContent());
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
|
var_dump($e);
|
||||||
$response->setStatus(404);
|
$response->setStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ use OCP\Files\SimpleFS\ISimpleFile;
|
||||||
use OCP\Files\SimpleFS\ISimpleFolder;
|
use OCP\Files\SimpleFS\ISimpleFolder;
|
||||||
use Sabre\CardDAV\Card;
|
use Sabre\CardDAV\Card;
|
||||||
use Sabre\VObject\Property\Binary;
|
use Sabre\VObject\Property\Binary;
|
||||||
|
use Sabre\VObject\Property\Uri;
|
||||||
use Sabre\VObject\Reader;
|
use Sabre\VObject\Reader;
|
||||||
|
|
||||||
class PhotoCache {
|
class PhotoCache {
|
||||||
|
@ -193,12 +194,13 @@ class PhotoCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
$photo = $vObject->PHOTO;
|
$photo = $vObject->PHOTO;
|
||||||
$type = $this->getType($photo);
|
|
||||||
|
|
||||||
$val = $photo->getValue();
|
$val = $photo->getValue();
|
||||||
|
|
||||||
|
// handle data URI. e.g PHOTO;VALUE=URI:data:image/jpeg;base64,/9j/4AAQSkZJRgABAQE
|
||||||
if ($photo->getValueType() === 'URI') {
|
if ($photo->getValueType() === 'URI') {
|
||||||
$parsed = \Sabre\URI\parse($val);
|
$parsed = \Sabre\URI\parse($val);
|
||||||
//only allow data://
|
|
||||||
|
// only allow data://
|
||||||
if ($parsed['scheme'] !== 'data') {
|
if ($parsed['scheme'] !== 'data') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -206,6 +208,9 @@ class PhotoCache {
|
||||||
list($type,) = explode(';', $parsed['path']);
|
list($type,) = explode(';', $parsed['path']);
|
||||||
}
|
}
|
||||||
$val = file_get_contents($val);
|
$val = file_get_contents($val);
|
||||||
|
} else {
|
||||||
|
// get type if binary data
|
||||||
|
$type = $this->getBinaryType($photo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowedContentTypes = [
|
$allowedContentTypes = [
|
||||||
|
@ -240,7 +245,7 @@ class PhotoCache {
|
||||||
* @param Binary $photo
|
* @param Binary $photo
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getType(Binary $photo) {
|
private function getBinaryType(Binary $photo) {
|
||||||
$params = $photo->parameters();
|
$params = $photo->parameters();
|
||||||
if (isset($params['TYPE']) || isset($params['MEDIATYPE'])) {
|
if (isset($params['TYPE']) || isset($params['MEDIATYPE'])) {
|
||||||
/** @var Parameter $typeParam */
|
/** @var Parameter $typeParam */
|
||||||
|
|
Loading…
Reference in New Issue