Skip to content
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

vcard CATEGORIES uses icalendar serilization #138

Closed
hildigerr opened this issue Mar 18, 2019 · 2 comments
Closed

vcard CATEGORIES uses icalendar serilization #138

hildigerr opened this issue Mar 18, 2019 · 2 comments

Comments

@hildigerr
Copy link

hildigerr commented Mar 18, 2019

icalendar registers icalendar.MultiTextBehavior for CATEGORIES (line 1603). This causes CATEGORIES values for vcards to be serialized incorrectly.

@hildigerr
Copy link
Author

hildigerr commented Mar 18, 2019

Something else in my own code must be causing this for me, because I can't reproduce it with

vobject.readOne('BEGIN:VCARD\r\nVERSION:3.0\r\nCATEGORIES;TYPE=Kind:Doctor\r\nFN:Dr. Given Middle Family IV\r\nEND:VCARD\r\n').serialize();

After building {'CATEGORIES': {'Kind': 'Doctor'}, 'FN': 'Dr. Given Middle Family IV'} from the result of readOne, for use in my application, and recreating a vcard from that for exporting from the application, I'm getting:

BEGIN:VCARD
VERSION:3.0
CATEGORIES;TYPE=Kind:D,o,c,t,o,r
FN:Dr. Given Middle Family IV
END:VCARD

Unless, I comment out registering icalendar CATERGORIES. I'll keep looking for the root cause.

@hildigerr
Copy link
Author

hildigerr commented Mar 18, 2019

My application maps vcard attributes into a dict by cardinality and type-param. From the RFC's ABNF format descriptions, I found that--of the attributes with cardinality of zero or more, and accepting a type-param--both CATEGORIES and NICNAME have values of text-list, while the rest are single URI or single structured. However, NICKNAME is serialized with vobject.vcard.VCardTextBehavior and CATEGORIES with vobject.icalendar.MultiTextBehavior.

vobject.readOne('BEGIN:VCARD\r\nVERSION:3.0\r\nCATEGORIES;TYPE=work:Doctor,med\r\nNICNAME;TYPE=home:Nick,Bob\r\nFN:Dr. Given Middle Family IV\r\nEND:VCARD\r\n').serialize()

Results in:

BEGIN:VCARD
VERSION:3.0
CATEGORIES;TYPE=work:Doctor,med
FN:Dr. Given Middle Family IV
NICNAME;TYPE=home:Nick
END:VCARD

Dropping the second nickname in the list, "Bob".

Using vobject, my application imports the vcard into:
{'NICKNAME': {'home': 'Nick'}, 'CATEGORIES': {'work': 'Doctor'}, 'FN': 'Dr. Given Middle Family IV'}
And exports back to:
BEGIN:VCARD
VERSION:3.0
CATEGORIES;TYPE=work:D,o,c,t,o,r
FN:Dr. Given Middle Family IV
NICKNAME;TYPE=home:Nick
END:VCARD

Mangling the CATEGORIES element.

If I handle NICKNAME and CATEGORIES as lists:
{'NICKNAME': {'home': ['Nick']}, 'CATEGORIES': {'work': ['Doctor']}, 'FN': 'Dr. Given Middle Family IV'}
An exception is raised when serializing the NICKNAME. However, using {'NICKNAME': {'home': 'Nick'}, 'CATEGORIES': {'work': ['Doctor']}, 'FN': 'Dr. Given Middle Family IV'} produces the desired result.

I'll hack the import/export of CATEGORIES and NICKNAMEs in my application, but I hope for some consistency in handling text-list value types when handling comma separated NICKNAMEs is repaired to not drop the tail of the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant