-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for properties with multiple values #5
Comments
I'd like to have a go at this. Hopefully I'm up to it. |
Ahah, added the label. :) This is a bit tricky since some properties might have multiple values, some won't. Also, it's more difficult than just creating one
vs
I'm not sure if that matters that much. Maybe reading the relevant parts of the RFC could help to decide. Also, escaping must be done properly. |
So tricky. That RFC is the most boring thing I've seen so far. I'll try. Maybe there might be insight in other vCard libraries. |
It seems this feature is already present in this library. According to RFC we have to escape comma-separated values in such properties that have multiple values, and in fact, in all properties.
I tried encoding such a field and it resulted in a backslash-escaped commas.
But decoding it worked. Importing the vCard in Evolution also worked. Then used the ExampleNewDecoder to decode the card, replacing the preferred value thus - log.Println(card.PreferredValue(vcard.FieldFormattedName))
+ log.Println(card.PreferredValue(vcard.FieldCategories)) The output was
Have I misunderstood the escaping rule? |
Yeah, this is done by https://github.com/emersion/go-vcard/blob/master/encoder.go#L74 and https://github.com/emersion/go-vcard/blob/master/decoder.go#L224. But this issue is not about fields with a single value containing a |
Does this imply that the comma in |
No. It means that for now, users cannot put multiple values in one field. They have to create two fields:
Also, as the RFC says, all commas must be escaped in field values ( |
I think we are interpreting incorrectly. CATEGORIES: cat1, cat2
This statement talks about value in multiple value context. i.e The comment talks about escaping "," within values and not when it acts as separator. Encoded |
#35 is an attempt to address this (quite old) issue. |
e.g.
CATEGORIES
The text was updated successfully, but these errors were encountered: