contacts icon indicating copy to clipboard operation
contacts copied to clipboard

Quotes in TYPE are still being set

Open nicokaiser opened this issue 3 years ago • 5 comments

Describe the bug

This is essentially #1107, which is still unresolved (but cannot be re-opened):

In the TYPE attribute, quotes are added:

EMAIL;TYPE="INTERNET,HOME,pref":[email protected]
TEL;TYPE="HOME,VOICE,pref":+49 123 456789
TEL;TYPE="CELL,VOICE":+49 123 456789

This leads to several platforms not interpreting these values correctly. On iOS this entry is being displayed as "CELL (presumably split at the ,).

In https://github.com/nextcloud/contacts/issues/1107#issuecomment-803477441 it is mentioned that changing the vCard version to 4.0 may fix this, so either the version has to be correct, or the quotes have to be removed.

Steps to reproduce

  1. Add a contact
  2. Add a cell phone numer
  3. Sync to iOS via CardDAV
  4. See the entry as "CELL

Expected behavior

The entry type should be Mobile (or something localized by iOS) instead of "CELL.

Actual behavior

The entry type is displayed as "CELL.

Contact version

4.2.0

Operating system

No response

PHP engine version

No response

Web server

No response

Database

No response

Additional info

No response

nicokaiser avatar Jul 23 '22 09:07 nicokaiser

In https://github.com/nextcloud/contacts/issues/1107#issuecomment-803477441 it is mentioned that changing the vCard version to 4.0 may fix this, so either the version has to be correct, or the quotes have to be removed.

I can confirm that this does not work. I changed the version number on my contacts list before importing at the quotes were still added.

I also tried importing the contacts, exporting them, manually fixing the field, and then re-importing it and the issue still appeared.

However, if I imported a contact, and then reset the TYPE attribute (i.e, from mobile -> none -> mobile), then the field is properly stored.

This leads me to believe that the issue is not with all contacts, but rather with import/export of them.

OmarWazzan avatar Jul 23 '22 09:07 OmarWazzan

I had this issue from the beginning, but today I have updated NextCloud to v24 and Contacts app to v4.2.0.

At first the issue was still there. See on my phone "HOME" instead of "domicile" (in french). I had to update manually phone type on all my contacts in the NextCloud web app. Now the problem is gone.

Types are correct on NextCloud web app and fortunately on my iPhone using iOS 15.6.

I guess there were something recorded badly in the contacts informations.

HooK81 avatar Aug 06 '22 19:08 HooK81

I had to update manually phone type on all my contacts in the NextCloud web app.

Unfortunately that's an infeasible solution for those of us with 500+ contacts

OmarWazzan avatar Aug 06 '22 20:08 OmarWazzan

Updating all contacts one by one worked for some versions now. However, at some point (!) the types break again, I did not figure out if it's after some time or after syncing with macOS (I don't use the web frontend for editing contacts). This is even more frustrating, when you spent hours fixing the contacts, and then after months the broken type names start to creep in again...

nicokaiser avatar Aug 06 '22 20:08 nicokaiser

This is happening to me too. I transitioned from mailbox.org contacts to nc contacts via export/import to nc webuiand the "CELL, "WORK etc appeared. I even tried exporting directly from Mac contacts (which was synced to Mailbox.org contacts and same thing. I have 600+ contacts so i do not want to have to edit everyone of them. Is there a way to batch regex edit the vcf file to temporarily correct this?

miguelarios avatar Aug 26 '22 18:08 miguelarios

Workaround (that worked for me) going from Apple to Nextcloud.

  1. Export from Apple in vCard
  2. Import into Google Contacts.
  3. Export from Google Contacts using vCard
  4. Import into Nextcloud

I assumed that googles code would clean up weird contact values on export which seems to be correct. (I cant remember if i read this somewhere or if I made it up, whatever it works.)

JonathanBouligny avatar Oct 19 '22 20:10 JonathanBouligny

Workaround (that worked for me) going from Apple to Nextcloud.

  1. Export from Apple in vCard

  2. Import into Google Contacts.

  3. Export from Google Contacts using vCard

  4. Import into Nextcloud

I assumed that googles code would clean up weird contact values on export which seems to be correct. (I cant remember if i read this somewhere or if I made it up, whatever it works.)

@JonathanBouligny i tried this just now but it skips about 200 or so of my 605 contacts. I don’t know why. Nextcloud registers the 605 contacts but my iPhone didn't sync all of them. Unsure why.

miguelarios avatar Oct 25 '22 20:10 miguelarios

What part skips 200 contacts? Step 1,2,3, or 4?

JonathanBouligny avatar Oct 27 '22 03:10 JonathanBouligny

@JonathanBouligny the last part syncing to iOS from Nextcloud CardDAV.

I looked at the final numbers and while my Nextcloud web had 605 my iPhone only had 500ish

miguelarios avatar Oct 31 '22 18:10 miguelarios

Maybe the culprit is Thunderbird's CardDAV implementation in this case:

  1. Create a contact in macOS Contacts, add a "Mobile" phone number:

The line in the VCF export looks like this:

TEL;TYPE=CELL,VOICE,pref:+1 555 0000000

Open Thunderbird and change something in the phone number (not the type):

TEL;TYPE="CELL,VOICE,pref":+1 555 0000001

  1. Wait for macOS to download the changes. It will display CELL,VOICE,pref instead of Mobile

macos-attr

At this point, also iOS decides to split the TYPE at commas (ignoring quotes) and use the first for display: "CELL

ios-attr

I am not sure if this is a Nextcloud issue, or if

  • Thunderbird is wrong by adding quotes around the type (which I assume), OR
  • macOS/iOS are wrong by splitting the quoted array of types

nicokaiser avatar Nov 04 '22 09:11 nicokaiser

From how I read the vCard Format Specification:

Property parameter values MUST NOT contain the DQUOTE (U+0022) character

So I added a bug report on Bugzilla for Thunderbird here: https://bugzilla.mozilla.org/show_bug.cgi?id=1799096

@miguelarios Could this be the case for your setup as well?

nicokaiser avatar Nov 04 '22 10:11 nicokaiser

@JonathanBouligny the last part syncing to iOS from Nextcloud CardDAV.

I looked at the final numbers and while my Nextcloud web had 605 my iPhone only had 500ish

Im not sure about that. I didn't have the issue getting them imported. I turned off all other contact stores except NextCloud. Id say try it again with those 100 contacts? Or reupload the whole thing a second time I think nextcloud can screen duplicates.

JonathanBouligny avatar Nov 07 '22 23:11 JonathanBouligny

@JonathanBouligny the last part syncing to iOS from Nextcloud CardDAV.

I looked at the final numbers and while my Nextcloud web had 605 my iPhone only had 500ish

This may be a separate problem than the quote problem. I suggest opening a new issue here on github.

JonathanBouligny avatar Nov 07 '22 23:11 JonathanBouligny

If i create the contact over the iPhone (added DAV account), the contact will be saved in Nextcloud Contacts with:

TEL;TYPE=CELL,VOICE,pref:45121542184 and is displayed correctly on both variants

If i create it instead in the Nextcloud Webapp directly in contacts app it creates as follows:

TEL;TYPE="CELL,VOICE,pref";VALUE=UNKNOWN:+21323568 (NOTE the VALUE=UNKNOWN here which seems to make problems)

Interessting Part here is: everything else seems to work with this kind of notation. for example ITEM1.ADR;TYPE="HOME,pref" = "Address" EMAIL;TYPE="INTERNET,HOME,pref" = "Private" in the Mail category. So the rest is correctly shown in the ios contacts.

I have now come to the conclusion that only the "Cell" is affected.

in Addition: The wrong one seems to create an "VALUE=UNKNOWN" tag which seems to be redundant.... failing: TEL;TYPE="CELL,VOICE,pref";VALUE=UNKNOWN:4565465 correct TEL;TYPE=CELL,VOICE,pref:45121542184

Possible Solution: From my point of view the problem should be solved as soon as the VALUE=UNKNOWN is not generated

In addition: If i import the corrected vcf without the VALUE=UNKNOWN, all contacts will be modified and include VALUE=UNKNOWN again.

In a next step i edited the contact on ios, and have choosen the type given by apple "Mobile" and "Work". after sync i downloaded the vcf contacts again.

the only contact i have changed on the Phone (and is correct now) is now shown as:

BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//iOS 16.2//EN
N:Marta;Main;;;
FN:Main Marta
ORG:ewz;
EMAIL;TYPE=INTERNET,WORK,pref:[email protected]
TEL;TYPE=WORK,VOICE,pref:+22222222222
TEL;TYPE=CELL,VOICE:+222222222
REV:2022-11-12T13:48:40Z
UID:3ad7bbb4-301f-4e0f-a7d7-d10985f695d4
END:VCARD

all the others (wrong ones):

BEGIN:VCARD
VERSION:3.0
PRODID;VALUE=TEXT:-//Apple Inc.//iOS 15.1.1//EN
N:Doe;John;;;
FN:John Doe
TEL;TYPE="WORK,VOICE,pref";VALUE=UNKNOWN:+45454545454
REV;VALUE=DATE-TIME:20211201T175114Z
UID:655a6301-e6cf-4271-9b86-661f65582bbb
END:VCARD

Hope this helps!!

plumped avatar Nov 12 '22 13:11 plumped

Hey there,

I am also having the same problem.

Steps:

  1. I recently migrated contacts from CardDAV hosted on All-Inkl to Nextcloud (v24.0.6).
  2. I exported the contacts as .vcf-file and used the Nextcloud contacts app to import the contacts
    • The vcf does not contain any quotes (see below for one contact that I adjusted to respect privacy)
BEGIN:VCARD
VERSION:4.0
UID:4dcf7bc1-2af9-44b5-a39d-12345679a0b3
FN:John Doe
N:Doe;John;;;
TEL;TYPE=home,voice;PREF=1:+1 (617) 123-4567
ORG:SomeCompany;
X-ABUID:D1234567-C0FD-4DBC-8DED-400C589BBA05:ABPerson
PRODID:-//WMAPI Contacts//WMAPI Contacts//EN
END:VCARD

Result:

  • Note: I have not editted the contacts yet at all. So the result is directly after the import
  • On iOS it shows "home
  • In the contacts app in Gnome/Ubuntu it (I assume it uses the fallback) Other
  • âž” So it seems to me (as also @plumped's comment indicates), that the Nextcloud Webapp creates the quotes

stephanbogner avatar Nov 14 '22 03:11 stephanbogner

Some investigation:

  • The Contacts Web App uses the function importContactsIntoAddressbook
    • It uses the function parseVFC ... but that doesn't seem to contain any flaws
    • It also calls contact.addressbook.dav.createVCard(vData) which might be the root cause ... but I couldn't find any createVCard-function in the code
    • Or more likely the line const vData = contact.vCard.toString()
      • Funnily the contact class has a function called toStringStripQuotes but it's not used in the above code :thinking:

stephanbogner avatar Nov 14 '22 04:11 stephanbogner

Some investigation:

* The Contacts Web App [uses](https://github.com/nextcloud/contacts/blob/1c1a1375db7abd755452a80aafedae06bdf4d173/src/components/AppNavigation/Settings/SettingsImportContacts.vue#L224) the function [importContactsIntoAddressbook](https://github.com/nextcloud/contacts/blob/1c1a1375db7abd755452a80aafedae06bdf4d173/src/store/addressbooks.js#L410)
  
  * It uses the function [parseVFC](https://github.com/nextcloud/contacts/blob/a7f286ae1605f61f72590661c8209da21ad636df/src/services/parseVcf.js#L34) ... but that doesn't seem to contain any flaws
  * It [also calls](https://github.com/nextcloud/contacts/blob/1c1a1375db7abd755452a80aafedae06bdf4d173/src/store/addressbooks.js#L426) `contact.addressbook.dav.createVCard(vData)`  which might be the root cause ... but I couldn't find any `createVCard`-function in the code
  * **Or more likely [the line](https://github.com/nextcloud/contacts/blob/1c1a1375db7abd755452a80aafedae06bdf4d173/src/store/addressbooks.js#L424) `const vData = contact.vCard.toString()`**
    
    * Funnily the contact class has a function called [toStringStripQuotes](https://github.com/nextcloud/contacts/blob/1c1a1375db7abd755452a80aafedae06bdf4d173/src/models/contact.js#L583) but it's not used in the above code thinking

So maybe the issue would be fixed if this line would be:

  • const vData = contact.toStringStripQuotes()
  • Instead of const vData = contact.vCard.toString()

But maybe a dev can jump in, as I don't know the codebase much :sweat_smile:

stephanbogner avatar Nov 14 '22 04:11 stephanbogner

@ChristophWurst Can you or someone of your team please see this issue? Thanks.

rakekniven avatar Nov 14 '22 08:11 rakekniven

Hey there,

I recently came accross the same issue when migrating from iCloud to Nextcloud.

Are there any updates for this issue?

Bl4DEx avatar Jan 08 '23 18:01 Bl4DEx

Hello,

I'm having the same problem. It's an annoying bug. Can this be fixed?

Thank you,

Soul

Soulplayer avatar Feb 06 '23 08:02 Soulplayer

I'm also having this issue and would love to see it resolved- maybe even a built in tool that can just go through the contacts and fix this?

Casuallynoted avatar Feb 17 '23 18:02 Casuallynoted

To the devs: I understand this issue is not high on the priority (because it‘s not critical). But as it affects all (or at least all migrating) iPhone users syncing their contacts over Nextcloud, it would be great if this could be resolved or at least some clarification given.

stephanbogner avatar Feb 20 '23 17:02 stephanbogner

I don't have time to look into this at the moment.

ChristophWurst avatar Feb 20 '23 17:02 ChristophWurst

But as it affects all (or at least all migrating) iPhone users

We had that issue in the past but since a while it is gone and working reliable on 10 devices. All of them are running iOS v16.3.x and communicating with NC v25.0.3 by using the latest contact app.

rakekniven avatar Feb 20 '23 17:02 rakekniven

But as it affects all (or at least all migrating) iPhone users

We had that issue in the past but since a while it is gone and working reliable on 10 devices. All of them are running iOS v16.3.x and communicating with NC v25.0.3 by using the latest contact app.

Awesome to hear! How did you resolve it @rakekniven? Did you manually fix the existing contacts or reimport? And by using the latest contact app do you mean the one in Nextcloud or iOS/MacOS/etc.? (I only use Nextcloud to store contacts and then editing and creating happens in native apps)

stephanbogner avatar Feb 20 '23 21:02 stephanbogner

I meant the Contacts app from Nextcloud v5.1.0. I usually do the editing with the Apple onBoard apps of macOS and iOS as well.

After it worked again, we started to manually fix (and also clean) the contacts when used. Not the best and effective way, but next time ;-)

It worked again after a BigSur update if I remember correctly. But unfortunately I don't have the details anymore.

rakekniven avatar Feb 20 '23 22:02 rakekniven

With this commit import contacts in nextcloud via web doesn't add the quotes anymore. So that IOS/Mac Addressbook shows correct labels.

caplod avatar Feb 23 '23 12:02 caplod

https://github.com/nextcloud/contacts/pull/3243 is in

ChristophWurst avatar Mar 06 '23 16:03 ChristophWurst

With this commit import contacts in nextcloud via web doesn't add the quotes anymore. So that IOS/Mac Addressbook shows correct labels.

That sounds awesome, thanks a lot!

stephanbogner avatar Mar 07 '23 18:03 stephanbogner

I see the update landed. Is there a way to fix these existing " quotes in bulk?

Soulplayer avatar Mar 17 '23 07:03 Soulplayer