VCard v3 import cannot handle ISO timestamp with milliseconds in REV
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):
- :x: vcard_v3_iso_milliseconds.vcf.txt
- :heavy_check_mark: vcard_v3_iso_seconds.vcf.txt
- :heavy_check_mark: vcard_v4_iso_milliseconds.vcf.txt
- :heavy_check_mark: 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