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

Use correct syntax for vCard version when saving #1393

Merged

Conversation

hanzi
Copy link
Member

@hanzi hanzi commented Jan 4, 2020

This changes the API used for serialising the vCard object into a string.

The previous method called ical.stringify on the underlying jCal object directly, which would always use vCard 4.x syntax regardless of the actual version used in the object.

If the vCard was still in 3.0 format, that would lead to invalid syntax being used. While clients seem to tolerate this most of the time, it breaks DAVx5 photo import.

Here's how the new call is being implemented in ical.js:
https://github.com/mozilla-comm/ical.js/blob/master/lib/ical/component.js#L487

fixes #1312

@hanzi hanzi force-pushed the use-correct-vcard-syntax-for-version branch from f49216c to fd7f83a Compare January 4, 2020 13:26
@codecov
Copy link

codecov bot commented Jan 4, 2020

Codecov Report

Merging #1393 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1393   +/-   ##
=======================================
  Coverage   62.31%   62.31%           
=======================================
  Files           4        4           
  Lines          69       69           
=======================================
  Hits           43       43           
  Misses         26       26

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 438e83e...b9f63e6. Read the comment docs.

@hanzi hanzi changed the title Use correct syntax for vCard version when saving [WIP] Use correct syntax for vCard version when saving Jan 5, 2020
@hanzi
Copy link
Member Author

hanzi commented Jan 5, 2020

Ok, this is annoying. While testing something else, I noticed an issue with this fix:

When saving a vCard in 3.0 format, ical.js adds VALUE=PHONE-NUMBER to TEL properties, at least sometimes. So a phone number would look like this:

TEL;TYPE=HOME;VALUE=PHONE-NUMBER:+123456789

According to the RFC this is correct, but our DAV backend doesn't recognise this value type and throws an error instead. I filed a PR for that (sabre-io/vobject#486) but even if this was merged, tagged and included in Nextcloud as soon as possible, older Nextcloud versions would still be broken. From what I understand, the Contacts app could be updated independently from Nextcloud, so that's a no-no.

@skjnldsv What would be your preferred way to deal with this?

The issue is with this line here: https://github.com/mozilla-comm/ical.js/blob/master/lib/ical/design.js#L830

The RFC doesn't actually require the value to be explicitely set, so if we patch the vCard 3 design set simliarly to what I've done in #1394 (something like delete ICAL.design.vcard3.property.tel in this case) would work around this problem.

An alternative would be to build a dedicated check that fixes these cases by explicitely making the value type URI. That doesn't actually conform to the vCard 3.0, but that's what we've been generating so far anyway and it seems to work with all relevant clients.

@skjnldsv
Copy link
Member

skjnldsv commented Jan 6, 2020

Wow, well done!!
I was always wondering why the heck the lib was behaving this way!!! 🤗

I couldn't figure it out and ran out ot time for contacts with other projects :)

According to the RFC this is correct, but our DAV backend doesn't recognise this value type and throws an error instead. I filed a PR for that (sabre-io/vobject#486) but even if this was merged, tagged and included in Nextcloud as soon as possible, older Nextcloud versions would still be broken

We can backport it then.
Let's add this and make our backend properly compliant :)
Alternatively, we could also indeed patch the lib.
I'm not sure VALUE=PHONE-NUMBER adds anything to our vcards. Especially considering no other vcard manager does it (apple, android, outlook, windows...)

So let's still add this to our backend for compatibility,
But patch the lib like you suggested.
(But I would create a dedicated js file for all those patches, not in the contacts model. This would greatly help understanding the code) 👍

@skjnldsv skjnldsv added 2. developing Work in progress bug Something isn't working high High priority labels Jan 6, 2020
@skjnldsv
Copy link
Member

skjnldsv commented Jan 6, 2020

And thanks a lot @hanzi! This is awesome work!! :D

Previously, vCards were always serialised in vCard 4.0
syntax, even if the vCard version was actually set to
something else.

Signed-off-by: Christian Kraus <hanzi@hanzi.cc>
…re-io/vobject

Signed-off-by: Christian Kraus <hanzi@hanzi.cc>
@hanzi hanzi force-pushed the use-correct-vcard-syntax-for-version branch from fd7f83a to b9f63e6 Compare January 6, 2020 11:42
@hanzi hanzi changed the title [WIP] Use correct syntax for vCard version when saving Use correct syntax for vCard version when saving Jan 6, 2020
@hanzi
Copy link
Member Author

hanzi commented Jan 6, 2020

We can backport it then.
Let's add this and make our backend properly compliant :)

I agree, that would be preferable.

But since sabre-io/vobject is a dependency of nextcloud/server we cannot rely on the backend having been fixed already: The user might use a fixed version of Contacts with an older version of Nextcloud Server. So this workaround is still necessary.

Anyway, I included the design set fix. Had no further issues with phone numbers while testing.

@skjnldsv skjnldsv added 3. to review Waiting for reviews 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress 3. to review Waiting for reviews labels Jan 6, 2020
@skjnldsv skjnldsv merged commit 67d106f into nextcloud:master Jan 6, 2020
@hanzi hanzi deleted the use-correct-vcard-syntax-for-version branch January 6, 2020 14:04
@skjnldsv skjnldsv added this to the next milestone Jan 18, 2020
@skjnldsv skjnldsv modified the milestones: next, 3.1.7-3.1.9 Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug Something isn't working high High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

contact photo not synced due to changed PHOTO value
2 participants