Skip to content

handle case-insensitive vCard tags and UID property - #5649

Open
mateeaaa wants to merge 1 commit into
nextcloud:mainfrom
mateeaaa:main
Open

handle case-insensitive vCard tags and UID property#5649
mateeaaa wants to merge 1 commit into
nextcloud:mainfrom
mateeaaa:main

Conversation

@mateeaaa

Copy link
Copy Markdown

Summary

This PR resolves an issue in ImportController where vCard files containing lowercase or mixed-case property tags (such as begin:vcard, end:vcard, or uid:...) were either skipped entirely or had their UID ignored during import.

Context & Root Cause

According to RFC 6350 Section 3.3 and RFC 2426, vCard property and parameter names are case-insensitive. Some contact export utilities output vCard delimiters and properties with lowercase or mixed-case formatting.

In ImportController.php:

  1. The parser checked $line === 'BEGIN:VCARD' and $line === 'END:VCARD' with strict case comparison. If a .vcf file contained begin:vcard, $currentContact was never initialized, causing contacts to be silently skipped.
  2. The check str_starts_with($line, self::UID_PREFIX) checked strictly for uppercase UID:. When a contact had uid:..., $currentContactUid remained null, preventing the existing contact deduplication lookup ($addressBook->search($uid, ...)) from executing and leading to duplicate entries upon re-import.

Solution

  • Use strtoupper($line) when comparing against BEGIN:VCARD and END:VCARD.
  • Use str_starts_with(strtoupper($line), self::UID_PREFIX) to reliably extract the UID regardless of casing.

Changes Made

  • lib/Controller/ImportController.php: updated BEGIN:VCARD, END:VCARD, and UID: tag checks to be case-insensitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants