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
16 stars 5 forks source link

[Not a Bug] URLs serialization in vcard 3.0 only serialize the first URL #7

Closed KhoiCanDev closed 1 year ago

KhoiCanDev commented 1 year ago

Describe the bug URLs serialization only serialize the first URL, other URLs are ignored

To Reproduce Please check this fiddle: https://dotnetfiddle.net/56fnoa

Expected behavior All URLs should be serialized. As in the example, a line group1.URL:http://facebook.com should be in the result

Desktop (please complete the following information):

Additional context Any reasons why in vcard 4.0 serialization code, you are using BuildPropertyCollection for the URLs (that serialize to the correct result), but in 3.0 and 2.1 you are using BuildPrefProperty that only serialize the first URL it found ?

FolkerKinzel commented 1 year ago

Thanks for posting the issue. vCard 3.0 supports the most properties by default as singletons. The "Formal Grammar" of RFC 2426, page 34 says that in the URL property no parameters are allowed. A vCard client that that supports only a single URL couldn't choose which one to pick.

The library picks the one with the highest preference (http://google.com in your example) and writes it to the VCF file.

The best workaround would be to use vCard 4.0. Alternatively VCard.InstantMessengerHandles might be your friend: It writes the instant messenger URLs by default as IMPP properties to the vCard 3.0. With setting the option VcfOptions.WriteNonStandardProperties you could also use VCard.NonStandardProperties in order to write additional X-URL properties to the vCard.

Multiple URL properties in vCard 3.0 doesn't seem to be widely supported by established E-Mail clients. Hope the tipps could help you and would close this issue by now. Should I be wrong feel free to open another one.