summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-07-01 11:36:35 +0200
committerLukas Reschke <lukas@owncloud.com>2016-07-01 11:36:35 +0200
commit179a355b2cd3dc489a54cc27fd717f67373d0b1e (patch)
treef87a5586086635d4cbd18771b442ee771f79e441 /apps/dav
parent8e002b61554308cb4d50570f715303a82136f0fa (diff)
parent2d2d2267f7f38ca29e7b87f40fae62261614b0d1 (diff)
downloadnextcloud-server-179a355b2cd3dc489a54cc27fd717f67373d0b1e.tar.gz
nextcloud-server-179a355b2cd3dc489a54cc27fd717f67373d0b1e.zip
Merge remote-tracking branch 'upstream/master' into master-sync-upstream
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CardDAV/ImageExportPlugin.php14
-rw-r--r--apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php9
2 files changed, 15 insertions, 8 deletions
diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php
index 3f505222491..fcd36b3ff35 100644
--- a/apps/dav/lib/CardDAV/ImageExportPlugin.php
+++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php
@@ -108,8 +108,18 @@ class ImageExportPlugin extends ServerPlugin {
$photo = $vObject->PHOTO;
$type = $this->getType($photo);
- $valType = $photo->getValueType();
- $val = ($valType === 'URI' ? $photo->getRawMimeDirValue() : $photo->getValue());
+ $val = $photo->getValue();
+ if ($photo->getValueType() === 'URI') {
+ $parsed = \Sabre\URI\parse($val);
+ //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);
+ }
return [
'Content-Type' => $type,
'body' => $val
diff --git a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
index 8583df0b6f9..3a9dc144584 100644
--- a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
+++ b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
@@ -140,12 +140,9 @@ class ImageExportPluginTest extends TestCase {
'empty vcard' => [false, ''],
'vcard without PHOTO' => [false, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nEND:VCARD\r\n"],
'vcard 3 with PHOTO' => [['Content-Type' => 'image/jpeg', 'body' => '12345'], "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;ENCODING=b;TYPE=JPEG:MTIzNDU=\r\nEND:VCARD\r\n"],
- //
- // TODO: these three below are not working - needs debugging
- //
- //'vcard 3 with PHOTO URL' => [['Content-Type' => 'image/jpeg', 'body' => '12345'], "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;TYPE=JPEG:http://example.org/photo.jpg\r\nEND:VCARD\r\n"],
- //'vcard 4 with PHOTO' => [['Content-Type' => 'image/jpeg', 'body' => '12345'], "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO:data:image/jpeg;MTIzNDU=\r\nEND:VCARD\r\n"],
- 'vcard 4 with PHOTO URL' => [['Content-Type' => 'image/jpeg', 'body' => 'http://example.org/photo.jpg'], "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;MEDIATYPE=image/jpeg:http://example.org/photo.jpg\r\nEND:VCARD\r\n"],
+ 'vcard 3 with PHOTO URL' => [false, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;TYPE=JPEG;VALUE=URI:http://example.com/photo.jpg\r\nEND:VCARD\r\n"],
+ 'vcard 4 with PHOTO' => [['Content-Type' => 'image/jpeg', 'body' => '12345'], "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO:data:image/jpeg;base64,MTIzNDU=\r\nEND:VCARD\r\n"],
+ 'vcard 4 with PHOTO URL' => [false, "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;MEDIATYPE=image/jpeg:http://example.org/photo.jpg\r\nEND:VCARD\r\n"],
];
}
}