nextcloud / nextcloud/contacts

VCF exported from Nextcloud 11 is imported incorrectly: Backslashes & semicolons get re-escaped, newlines \n replaced with ^n

Open
#3,310 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage bug feature: contacts feature: import
Dominant language
JavaScript
Stars
642
Forks
220
Avg merge
14h 39m
Merged PRs (30d)
51

Description

Describe the bug

I'm trying to migrate my contacts from an old Nextcloud 11 instance to a new one running Nextcloud 26, by exporting my contacts from the former and importing them into the latter.

I have validated the vcf file I exported from Nextcloud 11 using sabre/vobject 4.2.2: No errors. The vcf file only contains VCARD 4.0 data.

Unfortunately, after importing the vcf file into Contacts on Nextcloud 26, the Contacts app shows \; in my contact NOTEs where, before, there were single semicolons ;. Moreover, after re-exporting the contacts again (for test purposes), newlines \n in LABELs have gotten replaced with ^n.

Steps to reproduce

I imported into Nextcloud 26 / Contacts 5.2.0:

BEGIN:VCARD
VERSION:4.0
PRODID:+//IDN bitfire.at//DAVx5/4.0-ose ez-vcard/0.11.2
UID:aa0c474d-f4ab-4f86-a82d-5df4e40c69cd
FN:John Doe
N:Doe;John;;;
TEL;TYPE=cell:+1 234567890
TEL:+44 234567890
EMAIL;TYPE=home:johndoe@gmail.com
ADR;TYPE=home;LABEL=Street 77\n12345 Town  \n :;;
 Street 77\,12345 Town;;;;
BDAY:19111111
REV:20211206T000220Z
END:VCARD
BEGIN:VCARD
VERSION:4.0
PRODID:+//IDN bitfire.at//DAVx5/4.2.3.1-ose ez-vcard/0.11.3
UID:072e8f73-524a-4e0d-83e3-e7ab2d567f43
FN:Max Mustermann
N:Mustermann;Max;;;
TEL;TYPE=cell:+55 555 5555555
BDAY:19880808
NOTE:This is a description containing semicolons\; it also contains line
 breaks\n\nand commas\,and a final line break\n
REV:20230101T000420Z
END:VCARD

When exporting the contacts again afterwards, I get:

BEGIN:VCARD
VERSION:4.0
PRODID:+//IDN bitfire.at//DAVx5/4.0-ose ez-vcard/0.11.2
UID:aa0c474d-f4ab-4f86-a82d-5df4e40c69cd
FN:John Doe
N:Doe;John;;;
TEL;TYPE=cell:+1 234567890
TEL:+44 234567890
EMAIL;TYPE=home:johndoe@gmail.com
ADR;TYPE=home;LABEL="Street 77^n12345 Town  ^n ":
 ;;Street 77\,12345 Town;;;;
BDAY:19111111
REV:20211206T000220Z
END:VCARD
BEGIN:VCARD
VERSION:4.0
PRODID:+//IDN bitfire.at//DAVx5/4.2.3.1-ose ez-vcard/0.11.3
UID:072e8f73-524a-4e0d-83e3-e7ab2d567f43
FN:John Hancock
N:Hancock;John;;;
TEL;TYPE=cell:+55 555 5555555
BDAY:19880808
NOTE:This is a description containing semicolons\\\; it also contains line
 breaks\n\nand commas\,and a final line break\n
REV:20230101T000420Z
END:VCARD

Notice how in the address LABEL the line break \n became ^n (while it stayed the same in the NOTE).

Meanwhile, the escaped semicolon \; inside the note got replaced with \\\;.

Expected behavior

The Contacts app should not modify the imported data. In particular, re-exporting the imported data should match the latter.

Actual behavior

Exporting the imported vcf yields modified data. Backslashes & semicolons get re-escaped in NOTEs, and in LABELS newlines \n get replaced with ^n which violates the RFC.

Moreover, even before the export the Contacts app already displays \; in my contacts' NOTEs, indicating that replacing \; with \\\; happened during import, not during the subsequent export.

As for \n -> ^n, I'm not entirely sure whether it is a bug in Contacts' import functionality or its export functionality, given I that I don't see ^n anywhere in the UI. (Then again I don't know whether Contacts displays the LABELs anywhere.)

Contact version

5.2.0

Operating system

Ubuntu 20.04 LTS

PHP engine version

Other

Web server

Apache (supported)

Database

PostgreSQL

Additional info

The server is running the nextcloud:26.0.0-apache Docker image with PostgreSQL.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Reproduce the import and re-export on Nextcloud 26 with Contacts 5.2.0 using the supplied VCF, then compare the NOTE and ADR LABEL values at each stage to determine whether escaping changes during import or export; done means the re-export preserves the original escaped semicolons and newline encoding.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php
Domain
backend, data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.