]> source.dussan.org Git - nextcloud-server.git/commitdiff
VCARDS don't hold binary data 2266/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 22 Nov 2016 20:26:49 +0000 (21:26 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Wed, 23 Nov 2016 12:30:32 +0000 (13:30 +0100)
* We need to base64 encode the avatar!
* Switched to vcard v4
* User proper data uri

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/dav/lib/CardDAV/Converter.php
apps/dav/tests/unit/CardDAV/ConverterTest.php

index 065c5494ec38fff7137b49964ac99359ee136bd3..ba0c4c2a2d535ce63f7cca2dce375ff9b9416453 100644 (file)
@@ -71,7 +71,7 @@ class Converter {
                                                break;
                                        case AccountManager::PROPERTY_AVATAR:
                                                if ($image !== null) {
-                                                       $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
+                                                       $vCard->add('PHOTO', 'data:'.$image->mimeType().';base64,' . base64_encode($image->data()));
                                                }
                                                break;
                                        case AccountManager::PROPERTY_EMAIL:
index 737bbd96aaafbcea66ade0e158b4f73c5f79b012..528b3aa9ef4ed09f669f361a62b1bb6160dc9fe7 100644 (file)
@@ -134,11 +134,45 @@ class ConverterTest extends  TestCase {
 
        public function providesNewUsers() {
                return [
-                       [null],
-                       [null, null, 'foo@bar.net'],
-                       [['cloud' => 'foo@cloud.net', 'email' => 'foo@bar.net'], null, 'foo@bar.net', 'foo@cloud.net'],
-                       [['cloud' => 'foo@cloud.net', 'email' => 'foo@bar.net', 'fn' => 'Dr. Foo Bar'], "Dr. Foo Bar", "foo@bar.net", 'foo@cloud.net'],
-                       [['cloud' => 'foo@cloud.net', 'fn' => 'Dr. Foo Bar'], "Dr. Foo Bar", null, "foo@cloud.net"],
+                       [
+                               null
+                       ],
+                       [
+                               null,
+                               null,
+                               'foo@bar.net'
+                       ],
+                       [
+                               [
+                                       'cloud' => 'foo@cloud.net',
+                                       'email' => 'foo@bar.net',
+                                       'photo' => 'data:image/jpeg;base64,MTIzNDU2Nzg5',
+                               ],
+                               null,
+                               'foo@bar.net',
+                               'foo@cloud.net'
+                       ],
+                       [
+                               [
+                                       'cloud' => 'foo@cloud.net',
+                                       'email' => 'foo@bar.net',
+                                       'fn' => 'Dr. Foo Bar',
+                                       'photo' => 'data:image/jpeg;base64,MTIzNDU2Nzg5',
+                               ],
+                               "Dr. Foo Bar",
+                               "foo@bar.net",
+                               'foo@cloud.net'
+                       ],
+                       [
+                               [
+                                       'cloud' => 'foo@cloud.net',
+                                       'fn' => 'Dr. Foo Bar',
+                                       'photo' => 'data:image/jpeg;base64,MTIzNDU2Nzg5',
+                               ],
+                               "Dr. Foo Bar",
+                               null,
+                               "foo@cloud.net"
+                       ],
                ];
        }
 
@@ -171,7 +205,7 @@ class ConverterTest extends  TestCase {
         */
        protected function getUserMock($displayName, $eMailAddress, $cloudId) {
                $image0 = $this->getMockBuilder(IImage::class)->disableOriginalConstructor()->getMock();
-               $image0->method('mimeType')->willReturn('JPEG');
+               $image0->method('mimeType')->willReturn('image/jpeg');
                $image0->method('data')->willReturn('123456789');
                $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
                $user->method('getUID')->willReturn('12345');