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.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@hamza221 hamza221 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for you pr, please make sure to :

  1. sign the commit properly
  2. Write a conventional commit message

@hamza221 hamza221 added bug Something isn't working 3. to review Waiting for reviews labels Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug Something isn't working feedback-requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants