nextcloud / nextcloud/contacts

VCard v3 import cannot handle ISO timestamp with milliseconds in REV

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

Nobody has claimed this yet.

1. to develop 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 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

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

Start with the attached vcard_v3_iso_milliseconds.vcf.txt and reproduce the failure through Contacts' Import contacts flow. Compare the working vCard v3 seconds and vCard v4 milliseconds files, then verify that the v3 millisecond REV timestamp imports without producing the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.