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

Tail of NICKNAME text-list values dropped #140

Open
hildigerr opened this issue Mar 18, 2019 · 4 comments
Open

Tail of NICKNAME text-list values dropped #140

hildigerr opened this issue Mar 18, 2019 · 4 comments

Comments

@hildigerr
Copy link

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".

See also: #138 for description of deeper issue due to inconsistent handling of text-list values.

@wpercy
Copy link
Contributor

wpercy commented Mar 19, 2019

@hildigerr thanks for the detailed description in #138, I'll definitely take a look at this and try to make the behavior more consistent.

@epposan
Copy link

epposan commented Mar 28, 2019

For the record: The same thing happens with the value field of NOTE contentlines: As soon as it contains a comma, the rest is stripped (possibly true for all 'text' type value fields)

Could it be that (formally) the issue here is not vobject's parsing, but the wrong format of the input? According to Vcard RFC 6350 (para 3.4): all commas should be escaped and newlines represented by "\n".

When I modify the end of Component.add(self, objOrName, group=None) to

obj.value=obj.value.replace(",","\,")
self.contents.setdefault(obj.name.lower(), []).append(obj)
return obj

then the yield obj at the end of Component.getchildren(self) returns the correct value, while without the comma replacement, it appears to return the part before the first comma (in fact: the first item in the list)

I did not look into the reverse direction, where the escaped comma should be unescaped on output (I am glad I got this far), but maybe it's an idea for a workaround for other incorrect Vcard export implementations?

I noticed that, when exporting a contact with a NOTE field containing commas from Apple's Contacts using iCould for Windows into Vcard format (.vcf), that commas are not escaped, also giving problems when parsing with vobject. If I change the input .vcf file to provide escaped commas, all works fine...

@hildigerr
Copy link
Author

hildigerr commented Mar 29, 2019

The RFC states that "Some properties may contain one or more values delimited by a COMMA character (U+002C). Therefore, a COMMA character in a value MUST be escaped with a BACKSLASH character (U+005C), even for properties that don't allow multiple instances (for consistency)."

So, only COMMAs which are part of the value should be escaped. As in:

NICNAME;TYPE=home:Bob,Man of many\, many\, many names

@epposan
Copy link

epposan commented Mar 29, 2019

@hildigerr You are right of course. That's why I tried obj.value=.... to override the object's value entry with the escaped version, but it may not be the correct way to do it. I am new to this module's code (and still trying to understand it)

IMHO it is not a problem in vobject, but with the input data. However, since the developers have implemented other 'workarounds' for incorrect implementations...

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

3 participants