Server: Validation error in vCard: ENCODING=BASE64 is not valid for this document type

Created on 3 Feb 2017  路  18Comments  路  Source: nextcloud/server

Steps to reproduce

  1. import an addressbook into a clean install of Nextcloud 11 containing contacts with base64 encoded images (e.g. from an older NC or OC version)
  2. Watch those contacts to be rejected (they won't import at all)

Expected behaviour
All contacts will be imported with their respective images

Actual behaviour
Contacts containing

PHOTO;TYPE=JPEG;ENCODING=BASE64:/9j/4AA...

get rejected with a log entry like this:

`{"reqId":"cfFVmtgvP4awyLzSyMV3","remoteAddr":"10.8.0.6","app":"webdav","message":"Exception: {\"Message\":\"HTTP\\/1.1 415 Validation error in vCard: ENCODING=BASE64 is not valid for this document type.\",\"Exception\":\"Sabre\\DAV\\Exception\\UnsupportedMediaType\",\"Code\":0,\"Trace\":\"#0 \\/var\\/www\\/nextcloud\\/3rdparty\\/sabre\\/dav\\/lib\\/CardDAV\\/Plugin.php(316): Sabre\\CardDAV\\Plugin->validateVCard('BEGIN:VCARD\\r\\nVE...', false)\n#1 [internal function]: Sabre\\CardDAV\\Plugin->beforeCreateFile('addressbooks\\/us...', 'BEGIN:VCARD\\r\\nVE...', Object(OCA\\DAV\\CardDAV\\AddressBook), false)\n#2 \\/var\\/www\\/nextcloud\\/3rdparty\\/sabre\\/event\\/lib\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\n#3 \\/var\\/www\\/nextcloud\\/3rdparty\\/sabre\\/dav\\/lib\\/DAV\\/Server.php(1070): Sabre\\Event\\EventEmitter->emit('beforeCreateFil...', Array)\n#4 \\/var\\/www\\/nextcloud\\/3rdparty\\/sabre\\/dav\\/lib\\/DAV\\/CorePlugin.php(525): Sabre\\DAV\\Server->createFile('addressbooks\\/us...', 'BEGIN:VCARD\\r\\nVE...', NULL)\n#5 [internal function]: Sabre\\DAV\\CorePlugin->httpPut(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#6 \\/var\\/www\\/nextcloud\\/3rdparty\\/sabre\\/event\\/lib\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\n#7 \\/var\\/www\\/nextcloud\\/3rdparty\\/sabre\\/dav\\/lib\\/DAV\\/Server.php(479): Sabre\\Event\\EventEmitter->emit('method:PUT', Array)\n#8 \\/var\\/www\\/nextcloud\\/3rdparty\\/sabre\\/dav\\/lib\\/DAV\\/Server.php(254): Sabre\\DAV\\Server->invokeMethod(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#9 \\/var\\/www\\/nextcloud\\/apps\\/dav\\/lib\\/Server.php(227): Sabre\\DAV\\Server->exec()\n#10 \\/var\\/www\\/nextcloud\\/apps\\/dav\\/appinfo\\/v2\\/remote.php(30): OCA\\DAV\\Server->exec()\n#11 \\/var\\/www\\/nextcloud\\/remote.php(165): require_once('\\/var\\/www\\/nextcl...')\n#12 {main}\",\"File\":\"\\/var\\/www\\/nextcloud\\/3rdparty\\/sabre\\/dav\\/lib\\/CardDAV\\/Plugin.php\",\"Line\":397,\"User\":\"beccon\"}","level":4,"time":"2017-02-03T17:32:56+00:00","method":"PUT","url":"\/nextcloud\/remote.php\/dav\/addressbooks\/users\/beccon\/contacts\/a0a74a88-f56b-4005-8b45-d0bd490f366c.vcf","user":"beccon","version":"11.0.1.2"}

`

3. to review bug dav

Most helpful comment

Same problem when syncing from my BlackBerry Passport, using Vcard format 2.1 if I recall correctly.

Gist : https://gist.github.com/Webbeh/4b544a82714136dc1962deef4cc03fe3

Can't, sadly, attach the VCard, because BlackBerry doesn't export them in the same way if you do it manually.

EDIT:
After adding "BASE64" in the allowed encoding list for vCard version 3.0 in 3rdparty/sabre/vobject/lib/Property.php, the vcard is imported correctly in NextCloud.

All 18 comments

Can you provide us with the vcard you are trying to import?
If you don't want to post it publicly feel free to send to <my username>@nextcloud.com

I have this error too. Here a vCard that cannot be imported, resulting in the error above:

BEGIN:VCARD VERSION:3.0 UID:/remote.php/dav/addressbooks/users/alex.detsch/Kontakte/de027e31-893a-4 1da-b77b-6e948dbbc134.vcf N;CHARSET=utf-8:Mustermann;Max;;; FN;CHARSET=utf-8:Max Mustermann X-MS-OL-DEFAULT-POSTAL-ADDRESS:0 EMAIL;TYPE=PREF,INTERNET:[email protected] X-MS-CARDPICTURE;TYPE=JPEG;ENCODING=BASE64:/9j/4AAQSkZJRgABAQEAkACQAAD/2wBD AAcFBQYFBAcGBQYIBwcIChELCgkJChUPEAwRGBUaGRgVGBcbHichGx0lHRcYIi4iJSgpKywrGi AvMy8qMicqKyr/2wBDAQcICAoJChQLCxQqHBgcKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKir/wAARCACVACcDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQ EAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1Fh ByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1 hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLD xMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAA AAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEI FEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZG VmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbH yMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD393CkA9TQD1JPFQ udzn9KRj27CgB7z/3Ofc0sfIyevrUAGTVgfKnPpmgCGT55MelFJHy5aigBw4yfSkpT92koAIxl qllO2M+/FNhHNJMeQKAGw/KpPeiiThFWigBW60lHagdaAJ4hhc1A3zTfjVg/JH9BVeLlifagBJ TlsUU1zlifeigB/anRj5hmm9qliX+VABM2EA9ajT5YyfWlnOXA9BQQdgUcmgCCipRGFGXNFAC9 TipUOF9SeaQeX1ApWJVSVGKAG+WN25z17CmvJt4UY96RCS5JPQU1+XNADV+duTRTfpRQBZjHzD 86WY8AUsY4J/CmOV3c8n0oAIxhc+9R7QPvH8BUjHEfpxUVAAXx90YoplFAF7olVh8zfU1YlOIz 71DH97PoKACQ8Ae+ajp0n3segxTaAGUUUUAWpjyBTYx8vPc0khyxp3RPw/nQBCTkk0UUUAMooo oAs7lY4I60rYI+p9aYn3snsKH6j2FACeX7mm7D2IP40mcHil3sO+frQA0qR2opfM9vyNFAEqfc b8Ka/wDrD9aKKAGHrSZoooAbRRRQB//Z X-MS-OL-DESIGN;CHARSET=utf-8:<card xmlns="http://schemas.microsoft.com/offi ce/outlook/12/electronicbusinesscards" ver="1.0" layout="left" bgcolor="ff ffff"><img xmlns="" align="fit" area="16" use="cardpicture"/><fld xmlns="" prop="name" align="left" dir="ltr" style="b" color="000000" size="10"/><f ld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="email" align="left" dir="ltr" color="d48d2a" size="8"/><fld xmlns="" prop="blank" size="8"/>< fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/>< fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/>< fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/>< fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/>< fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/>< fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/>< /card> REV:20160522T185141Z END:VCARD

I use Z-Push and have the same problem when changing contacts with pictures. Is there any solution?

cc @georgehrke

Same problem when syncing from my BlackBerry Passport, using Vcard format 2.1 if I recall correctly.

Gist : https://gist.github.com/Webbeh/4b544a82714136dc1962deef4cc03fe3

Can't, sadly, attach the VCard, because BlackBerry doesn't export them in the same way if you do it manually.

EDIT:
After adding "BASE64" in the allowed encoding list for vCard version 3.0 in 3rdparty/sabre/vobject/lib/Property.php, the vcard is imported correctly in NextCloud.

After adding "BASE64" in the allowed encoding list for vCard version 3.0 in 3rdparty/sabre/vobject/lib/Property.php, the vcard is imported correctly in NextCloud.

Works for me as well. Could we add this a offical fix?

I had the same problem and Webbeh's solution is working for me as well.

I understand that ENCODING=BASE64 is not valid in the official DAV specifications, but accepting it adds compatibility with poorly written implementations, and I don't think it would actually hurt to add it.

I updated the GIST with the same error on 13.0.2.1.

Fixed in the same way, adding "BASE64" as allowed encoding in Property.php for vCard v3.

UPDATE : Same fix in 13.0.4

UPDATE 2 :
I just submitted a PR in the upstream vobject library in sabre-io, if anyone is interested in commenting on this.
https://github.com/sabre-io/vobject/pull/415

Can this be merged? This is an annoying issue...

Don't mind, I now see it's a 3rd party library.
For anyone getting here and who cannot wait for sabre to solve this: https://github.com/sabre-io/vobject/pull/415/files fixes it all.

Bump!

The issue 51d7d7 was closed, but not fixed. Subsequently, ENCODIG=BASE64 is still not supported. I made a comment in that Pull Request about this.

ENCODING=BASE64 is not valid in vCard 3. Supporting broken vCard implementations is kind of a bad idea, because it means that sabre/dav will also serve broken vCards to other clients.

I think you should report the bug first to blackberry and see if they can fix it. If they refuse or don't respond, we can reopen this discussion.

https://github.com/sabre-io/vobject/pull/415#issuecomment-399797622

I didn't know!

In that case, I would propose the following:

Change your PR to not remove the error, but instead 'repair' the problem (with the REPAIR option) . Repairing in this case is simply changing the BASE64 into B and setting the warning level to 1 instead of 3 (but only if REPAIR was passed).

sabre/dav will call validate with the repair option by default, so this should fix your problem in a more correct way

https://github.com/sabre-io/vobject/pull/415#issuecomment-399818458

Don't mind, I now see it's a 3rd party library.

What do you suggest? First this needs to be fixed in sabre/vobject. Are you using a blackberry with OS10 as well?

https://github.com/sabre-io/vobject/pull/441

I suggested a PR for this to finally be resolved upstream, with a proper repairing of the vCard instead of a simple hack to allow the badly formatted one to pass.

Hopefully this will be solved quite soon.

This has now been resolved upstream, with the aforementioned PR.
@nickvergessen

Sorry danielkesselberg, went for 1b :)

That鈥檚 great, many thanks!
So how will Nextcloud be updated from an upstream update? Do you merge
updates in sabre and other libraries once in a while?

  1. Pull Request is merged but there is no release yet with this patch. There are two ways to go ahead:
    a. Wait for a new release and update 3rdparty
    b. Apply patch to 3rdparty
  2. Create a pull request here to use the new 3rdparty submodule.

3rdparty? https://github.com/nextcloud/3rdparty/ this repository is linked to this repository as git submodule. Dependencies are updated there.

I would go for 1a like i did here for the same dependency: https://github.com/nextcloud/3rdparty/pull/191/files (wget https://patch-diff.githubusercontent.com/raw/sabre-io/vobject/pull/441.patch, patch < 441.patch and commit changes to 3rdparty repository, setup a new pr)

Wow still not merged

Was this page helpful?
0 / 5 - 0 ratings