contacts icon indicating copy to clipboard operation
contacts copied to clipboard

VCard v3 import cannot handle ISO timestamp with milliseconds in REV

Open fxedel opened this issue 2 years ago • 0 comments

Describe the bug

I'm currently migrating from ownCloud to nextCloud, so I exported my contacts in ownCloud as a huge .vcf file and imported that file in nextCloud. However, during the import, 22 of 864 contacts failed (sidenote: it would have been helpful if the dialog mentioned which contacts failed or why they failed). After some investigation, I found out that the REV field in the .vcf file caused the problem: Some contacts use a unix timestamp, e.g. REV:20230609T213743Z, which works fine, some use ISO timestamps without milliseconds, e.g. REV:2016-12-07T13:12:25Z, which also works fine. But some use ISO timestamps with milliseconds, e.g. REV:2016-12-07T13:12:25.380Z, and these contacts were exactly those that could not be imported. All of these contacts were VERSION:3.0.

I removed the milliseconds part in the .vcf file by using the regex replacement ^REV:(.*)\.\d+Z$ -> REV:$1Z and voila, all of my 864 contacts could be imported successfully.

I also created a minimal contact file (vcard_v3_iso_milliseconds.vcf) which cannot be imported:

BEGIN:VCARD
VERSION:3.0
N:Test;Mister;;;
REV:2016-12-07T13:12:25.380Z
END:VCARD

Removing the millisecond part (.380) from the timestamp or just changing the VERSION to 4.0 makes the contact file importable again.

Here are all my test files (file ending is .vcf.txt due to GitHub's file upload restrictions):

Steps to reproduce

  1. Go to Contacts
  2. Click on Import contacts
  3. Import vcard_v3_iso_milliseconds.vcf
  4. See error

Expected behavior

No error

Actual behavior

"1 error"

Contact version

5.4.2

Operating system

No response

PHP engine version

Other

Web server

Other

Database

Other

Additional info

NextCloud version: 27.1.2 PHP Version: 8.2 Webserver: OpenResty (nginx) Database: MariaDB 10.5

fxedel avatar Oct 15 '23 13:10 fxedel