vobject icon indicating copy to clipboard operation
vobject copied to clipboard

Incorrect PHOTO conversion from 3.0 to 4.0

Open blacksenator opened this issue 5 years ago • 2 comments

RFC2426 shows the following example for 3.0:

PHOTO;ENCODING=b;TYPE=JPEG:,[base64-data]

For my project I´m actually handle only JPEGs in Version 3.0 vCards and adding this property in this way:

$vcard->add('PHOTO', $base64data, ['TYPE' => 'JPEG', 'ENCODING' => 'b']);

which works perfectly. After converting (for test purposes) this property shows:

PHOTO;VALUE=URI:data:image/jpeg;base64\,[base64-data]

which does not correspond to the RFC RFC6350:

PHOTO:data:image/jpeg;base64,[base64-data]

blacksenator avatar Jun 05 '19 06:06 blacksenator

There is a complication with the vcard specification in that it has conflicting information about this:

https://www.rfc-editor.org/errata/eid3845

Unfortunately this is therefore a little bit open to interpretation. I don't think the serialization that is used is necessarily wrong. It's simply impossible to do this right :(

evert avatar Jun 05 '19 15:06 evert

According to your answer: What is the correct function parameter three for creating a Version 4.0 PHOTO property?

$vcard->add('PHOTO', $base64data, [ARRAY]);

I tried ['VALUE' => 'URI:data:image/jpeg;base64\'] but received:

Unsupported VALUE parameter for PHOTO property. You supplied "URI:data:image/jpeg;base64\"

I have not tried the keys TYPE and encoding - because this is obviously incorrect for version 4.0!

+++UPDATE+++ I found only this solution - looks not very smart:

$vcard->add('PHOTO', 'data:' . $mimetype . ';base64,' . base64_encode([$base64_data]));

blacksenator avatar Jun 06 '19 11:06 blacksenator