Coder Social home page Coder Social logo

Comments (7)

mangstadt avatar mangstadt commented on July 3, 2024 1

The example you gave in your first post isn't quite accurate.

N:Public;John;Quinlan;Mr.;Esq.

The reason why there is no trailing semicolon in this example is that there are no more components after the "Esq." component. "Esq." is the "suffix" component, which is the last one.

The formal grammar in the vCard 3.0 spec does state that trailing semicolons are optional:

 ;For name="N"
 ;This type MUST be included in a vCard object.
 param = text-param
 ; Text parameters allowed
 value = n-value
 n-value = 0*4(text-value *("," text-value) ";")
 text-value *("," text-value)
 ; Family; Given; Middle; Prefix; Suffix.
 ; Example: Public;John;Quincy,Adams;Reverend Dr. III

And the vCard 2.1 spec gives an example without the trailing semi-colons:

N:Veni, Vidi, Vici;The Restaurant.

However, vCard 4.0 requires all four semicolons to be there:

N-value = list-component 4(";" list-component)

From a performance perspective, the better approach would be to trim the semicolons, since it reduces the size of the vCard file.

Trailing semicolons are now trimmed by default for 2.1 and 3.0 vCards. I removed TargetApplication.ICLOUD and added a method to VCardReader that lets you adjust this setting if the consumer you're targeting requires something specific.

See commits 04cd767 and 882ee75.

from ez-vcard.

mangstadt avatar mangstadt commented on July 3, 2024

Is there a typo in your first example? Should those commas be semi-colons?

Commas and semi-colons are treated differently by the N property. Commas are used as delimiters when a component has more than one item in it.

For example, the following property has two prefixes:

N:Public;John;Quinlan;Mr.,Dr.;Esq.;

The first example you gave technically translates as a list of family names. According to the specification, it is not possible to have more than one family name, so iCloud may be treating the comma characters as normal characters, which is why iCloud is using "My Group,,,," as the group name.

What happens when you pass N:GroupName;;;; into iCloud? Does iCloud include the trailing semicolons in the group name?

from ez-vcard.

rfc2822 avatar rfc2822 commented on July 3, 2024

What happens when you pass N:GroupName;;;; into iCloud? Does iCloud include the trailing semicolons in the group name?

You're right, this is a typo. I have passed a StructuredName which just family name set into iCloud and the result was a group called Name,,,, or Name;;;;. I don't remember anymore, but I guess it was "Name;;;;" (because this was the full N in the uploaded VCard). When doing vCard.addExtendedProperty("N", fn); instead, it works.

from ez-vcard.

mangstadt avatar mangstadt commented on July 3, 2024

Fixed in e2a4dd3.

Call VCardWriter.setTargetApplication() like so:

VCard vcard = new VCard();
StructuredName n = new StructuredName();
n.setFamily("GroupName");
vcard.setStructuredName(n);

VCardWriter writer = new VCardWriter(System.out, VCardVersion.V3_0);
writer.setTargetApplication(TargetApplication.ICLOUD);
writer.write(vcard);
writer.close();

Output:

BEGIN:VCARD
VERSION:3.0
PRODID:ez-vcard 0.9.11-SNAPSHOT
N:GroupName
END:VCARD

Thank you for reporting this.

from ez-vcard.

rfc2822 avatar rfc2822 commented on July 3, 2024

Thanks, but one question: As far as I understand it, the trailing ;s are unnecessary in any case, so wouldn't it best to always remove them (and not only for a specific target application)?

from ez-vcard.

rfc2822 avatar rfc2822 commented on July 3, 2024

From a performance perspective, the better approach would be to trim the semicolons, since it reduces the size of the vCard file.

Yes, this was my first thought.

Thank you very much for digging into this and providing this enhancement!

from ez-vcard.

mangstadt avatar mangstadt commented on July 3, 2024

No problem. Thanks for bringing the issue to my attention!

from ez-vcard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.