FolkerKinzel / VCards

.NET library for reading, writing, and converting VCF files that comply with vCard standards 2.1, 3.0 and 4.0
MIT License
14 stars 4 forks source link

[Feature Request] UID parsing fails for values others than UUIDs #9

Open RobSlgm opened 2 weeks ago

RobSlgm commented 2 weeks ago

Describe the bug

UID of some VCARD 3.0 items are not properly recognized.

To Reproduce

using FolkerKinzel.VCards;

string vcard3 = @"
BEGIN:VCARD
VERSION:3.0
REV:2010-03-29T09:23:34Z
UID:dd72824a-cfda-457f-ae74-d70c2711e532@example.org
N:Dude;Some;Fred;;
FN:Some dude
NOTE:Simplified card for testing (Sogo Connector)
NICKNAME:fred
ROLE:Geek
END:VCARD
";

var vcard = Vcf.Parse(vcard3).FirstOrDefault();
if (vcard is not null)
{
    Console.WriteLine($"Version: {vcard.Version}");
    Console.WriteLine($"UID:     {vcard.ID?.Value}  (Should be 'dd72824a-cfda-457f-ae74-d70c2711e532@example.org')");
    Console.WriteLine($"Note:    {vcard.Notes}");
}

Expected behavior

see https://datatracker.ietf.org/doc/html/rfc6350#section-6.7.6, UID --> "Free-form text MAY also be used."

To avoid breaking the current UID UUID typing, maybe offer the original unmodified UID in a separate property

FolkerKinzel commented 2 weeks ago

Thanks for posting this issue.

To keep things simple, in version 1.4.4 I decided to only support UID properties whose value can be converted to Guid instances. Looking back, that probably wasn't the best decision.

You are right: The IDProperty class should support free-form text as well as URIs and UUIDs and should apply different comparison rules depending on the content. (This would of course have side effects on the handling of the vCard properties MEMBER and RELATED.)

Unfortunately, all of this cannot be implemented without API changes, so it will have to wait until the next major release.