nextcloud / nextcloud/contacts
VCard v3 import cannot handle ISO timestamp with milliseconds in REV
Nobody has claimed this yet.
- 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):
- ❌ vcard_v3_iso_milliseconds.vcf.txt
- ✔️ vcard_v3_iso_seconds.vcf.txt
- ✔️ vcard_v4_iso_milliseconds.vcf.txt
- ✔️ vcard_v4_iso_seconds.vcf.txt
Steps to reproduce
- Go to Contacts
- Click on Import contacts
- Import
vcard_v3_iso_milliseconds.vcf - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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