Skip to content

fix(VCardConverter): map WebP photos between vCard 3.0 and 4.0 - #813

Open
nursoda wants to merge 1 commit into
sabre-io:masterfrom
datenschutz-individuell:webp-photo-conversion
Open

nursoda wants to merge 1 commit into
sabre-io:masterfrom
datenschutz-individuell:webp-photo-conversion

Conversation

@nursoda

@nursoda nursoda commented Nov 4, 2026 •

Copy link
Copy Markdown

Converting a vCard 4.0 PHOTO:data:image/webp;base64,… to 3.0 currently yields PHOTO;ENCODING=b without a TYPE parameter. Clients that request vCard 3.0 – e.g. a FRITZ!Box CardDAV phonebook served by Nextcloud – then cannot tell the image format and show no photo, although they display the same image fine when the card is stored as 3.0 with TYPE=WEBP. The reverse direction turns TYPE=WEBP into data:application/octet-stream and keeps WEBP as a plain TYPE value.

This PR:

  • adds WEBP next to JPEG, PNG and GIF in both convertBinaryToUri() and convertUriToBinary()
  • compares the media type of the data: URI case-insensitively (RFC 2045), so data:image/WEBP is mapped as well
  • recognises the MIME form TYPE=image/<format> (written by some clients instead of the short name) in 3.0 → 4.0
  • extends testConvert30to40 and testConvert40to30 accordingly; the new lines fail without the fix

Backports: #814 (4.6) and #815 (4.5). Nextcloud 33–35 ship sabre/vobject 4.5.x, so a 4.5 release would get the fix to their users.

Related gaps in the same functions, left out to keep this focused: #812 (data: URI parsing) and #811 (format mapping listed twice, other image types). Happy to send PRs for those if wanted.

🤖 Generated with Claude Code

Converting a vCard 4.0 PHOTO with a data:image/webp URI to 3.0 produced PHOTO;ENCODING=b without a TYPE parameter, so clients that read 3.0 (e.g. FRITZ!Box CardDAV phonebooks) cannot tell the image format and show no photo. The reverse direction turned TYPE=WEBP into data:application/octet-stream and kept WEBP as a plain TYPE value.

Add WEBP next to JPEG, PNG and GIF in both directions. Media types are case-insensitive (RFC 2045), so compare the data: URI type in lower case. In 3.0 → 4.0, also recognise the MIME form TYPE=image/<format> that some clients write instead of the short name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Olav Seyfarth <olav@seyfarth.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant