handle case-insensitive vCard tags and UID property - #5649
Conversation
|
Hello there, 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.) |
Summary
This PR resolves an issue in
ImportControllerwhere vCard files containing lowercase or mixed-case property tags (such asbegin:vcard,end:vcard, oruid:...) 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:$line === 'BEGIN:VCARD'and$line === 'END:VCARD'with strict case comparison. If a.vcffile containedbegin:vcard,$currentContactwas never initialized, causing contacts to be silently skipped.str_starts_with($line, self::UID_PREFIX)checked strictly for uppercaseUID:. When a contact haduid:...,$currentContactUidremainednull, preventing the existing contact deduplication lookup ($addressBook->search($uid, ...)) from executing and leading to duplicate entries upon re-import.Solution
strtoupper($line)when comparing againstBEGIN:VCARDandEND:VCARD.str_starts_with(strtoupper($line), self::UID_PREFIX)to reliably extract the UID regardless of casing.Changes Made
lib/Controller/ImportController.php: updatedBEGIN:VCARD,END:VCARD, andUID:tag checks to be case-insensitive.