vobject
vobject copied to clipboard
Wrong data escaping in PHOTO property
When generating a vCard 4.0 with a PHOTO-Tag, the comma after data:image/png;base64
is escaped.
I use the following php-code
// current version: "sabre/vobject": "4.1.2"
$vcard = new \Sabre\VObject\Component\VCard();
$vcard->add('PHOTO', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg[...]');
The output line of the PHOTO-tag is now:
PHOTO;VALUE=URI:data:image/png;base64\,iVBORw0KGgoAAAANSUhEUg[...]
but should be like the following (without the \
before the comma)
PHOTO;VALUE=URI:data:image/png;base64,iVBORw0KGgoAAAANSUhEUg[...]
because otherwise the image cannot be parsed in the addressbook clients.
I also tried to generate a vCard with VERSION: 3.0
and convert it to VERSION: 4.0
, which also produced in the same result:
$vcard = new VCard([
'VERSION' => '3.0'
]);
$vcard->add('PHOTO', 'iVBORw0KGgoAAAANSUhEUg[...]', ['ENCODING' => 'BASE64', 'TYPE' => 'PNG]));
$vcard = $vcard->convert(\Sabre\VObject\Document::VCARD40);
My current "solution" is to use the v3 without converting to v4
@mschering already mentioned this bug in the closed issue https://github.com/fruux/sabre-vobject/issues/294#issuecomment-231987064