Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contact photo not synced due to changed PHOTO value #1312

Closed
j-ed opened this issue Oct 23, 2019 · 8 comments · Fixed by #1393
Closed

contact photo not synced due to changed PHOTO value #1312

j-ed opened this issue Oct 23, 2019 · 8 comments · Fixed by #1393
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working

Comments

@j-ed
Copy link

j-ed commented Oct 23, 2019

Expected behavior

An uploaded contact photo should be stored so that it can correctly been synced e.g. with DAVx5.

Current behavior

Newly uploaded contact photos are not synced anymore, due to a different syntax used for the PHOTO value. Unfortunately I don't know if DAVx5 is lacking support of this syntax or if it is a problem within Nextcloud.

(1) - Working syntax: PHOTO;ENCODING=b;TYPE=JPEG:/9j/4AAQSkZJRgA ...

(2) - Failing syntax: PHOTO;ENCODING=b;TYPE=jpeg;VALUE=URI:/9j/4AAQSkZJRgAB ...

Steps to reproduce

  1. Open the contacts app
  2. select a contact and upload a photo.
  3. check the used CardDAV syntax by exporting a vcf file.
  4. force a contact sync in DAVx5
    -> the photo is not synced (2)

Cross-check

  1. Open Thunderbird (v68.2.0) with activated CardBook (v42.9) add-in
  2. select a contact and upload a photo.
  3. check the used CardDAV syntax by exporting a vcf file from within the Nextcloud contacts app
  4. force a contact sync in DAVx5
    -> the photo is synced (1)

Environment

Server Configuration

OS: Linux 3.16.74
Web server: Apache2 2.4.41
Database: MariaDB 10.2.24
PHP version: 7.3.10
Nextcloud version: 17.0.0
Contacts app version: 3.1.6

Client Configuration

Browser: Mozilla Firefox 70.0
Operating system: Windows 10

@j-ed j-ed added 0. to triage Pending approval or rejection. This issue is pending approval. bug Something isn't working labels Oct 23, 2019
@skjnldsv
Copy link
Member

Interesting. :)
@rfc2822, any clue on this?
I'm guessing VALUE=URI: should not cause any issues according to the rfc, right?

@skjnldsv skjnldsv added the needs info Not enough information provided label Oct 23, 2019
@rfc2822
Copy link
Contributor

rfc2822 commented Oct 24, 2019

Are we talking about vCard 3 or vCard 4? They have different PHOTO syntax. DAVx⁵ understands both versions, but they cannot be mixed.

ENCODING=b is vCard 3 syntax, but Nextcloud supports vCard 4 and DAVx⁵ uses vCard 4 when possible.

value=URI always means that the value is specified as URI, and /9j/4AAQSkZJR… is not an URI (there is no URI scheme).

I would need more information, including logs, but the problem seems to come from wrongly mixed vCard 3 and 4 syntax.

@skjnldsv
Copy link
Member

skjnldsv commented Oct 25, 2019

value=URI always means that the value is specified as URI, and /9j/4AAQSkZJR… is not an URI (there is no URI scheme).

This is most likely the issue (this is added by our library automatically)
Because we do a clear distinction between the two vcard version

if (this.contact.version === '3.0') {
// check if photo property exists to decide whether to add/update it
this.contact.photo
? this.contact.photo = data
: this.contact.vCard.addPropertyWithValue('photo', data)
const photo = this.contact.vCard.getFirstProperty('photo')
photo.setParameter('encoding', 'b')
if (type) {
photo.setParameter('type', type.split('/').pop())
}
} else {
// https://tools.ietf.org/html/rfc6350#section-6.2.4
// check if photo property exists to decide whether to add/update it
this.contact.photo
? this.contact.photo = `data:${type};base64,${data}`
: this.contact.vCard.addPropertyWithValue('photo', `data:${type};base64,${data}`)
}
:)

@j-ed
Copy link
Author

j-ed commented Oct 25, 2019

value=URI always means that the value is specified as URI, and /9j/4AAQSkZJR… is not an URI (there is no URI scheme).

I would need more information, including logs, but the problem seems to come from wrongly mixed vCard 3 and 4 syntax.

Thank you @rfc2822 this seems indeed the case. For me it looks like the Contacts app uses the vCard 4-syntax for the photo value although the general record is a vCard 3 one by default:

BEGIN:VCARD
VERSION:3.0
PRODID:-//ownCloud//NONSGML Contacts 0.3.0.18//EN
...

@Ra72xx
Copy link

Ra72xx commented Nov 24, 2019

This is a VERY annoying bug. It leads to data corruption with contacts, a kind of precious data piece in my personal cloud :-( .

I wondered why my setup with DAVx5, Evolution and Nextcloud in many cases no longer really syncs the contacts between the devices. Contact pictures are showing up very unreliable (e.g. suddenly reappearing when switching to Nextcloud's contact detail view etc.) Adress information is entered on one device and does not propagate to other devices (failing often silently).

As there is no user-visible information when (and which) contact failed to sync, the data on the different devices begins to diverge and address information got lost.

As a first fix I exported all contacts from Nextcloud, deleted them in Nextcloud, and wanted to reimport them. This fails for lots of contacts (probably those with the wrong PHOTO field, but I don't know, as the importer does not tell the users which contact failed to get imported, in itself a very unsatisfying behaviour).

Right now I manually edited the exported contacts file and search/replaced the wrong photo lines. This imports flawlessly, I just fear that the next changes in one of the devices (Android, Linux, Nextcloud web) again messes ups the contacts.

@skjnldsv skjnldsv added 1. to develop Accepted and waiting to be taken care of and removed 0. to triage Pending approval or rejection. This issue is pending approval. needs info Not enough information provided labels Dec 3, 2019
@solarchemist
Copy link

Thanks for opening this issue. I used a QR reader (e.g. BinaryEye) to view the generated QR-code for a contact whose picture refused to sync to DavX5/Android, and noted that it said version 3, whereas most other contacts in my list appear to be on version 4.
So that probably explains why that contact's photo refuses to sync.

This is on Nextcloud 19.x, and the contacts on this server have been around since at least v12 or so.
Is there perhaps any occ database command one could use to bring all Contacts into line? Or is the only fix to manually identify and recreate the troublesome contacts from scratch?

@j-ed
Copy link
Author

j-ed commented Feb 7, 2021

@solarchemist This issue has already been closed beginning of last year, which means it was fixed already. If you want to report a new issue, please open a new ticket, if you're seeking for help, please post your question on the Nextcloud help forum.

@ltguillaume
Copy link

@j-ed As far as I know, this isn't quite fixed. I get a different result, but it still results in my contacts in Android not showing any picture. I'm running Nextcloud 20.0.7 and just uploaded a picture. Part of the exported vcf:

BEGIN:VCARD
VERSION:3.0
N:Last;First;;;
FN:First Last
TEL;TYPE=PREF;VALUE=UNKNOWN:+(...)
TEL;TYPE=CELL;VALUE=UNKNOWN:+(...)
PHOTO;ENCODING=b;TYPE=jpeg;VALUE=BINARY:/9j/4AAQSkZJ(...)
UID:(...)
REV;VALUE=DATE-AND-OR-TIME:(...)
PHOTO:
END:VCARD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants