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

Make vobject python3-compatible #20

Closed
prauscher opened this issue Apr 2, 2016 · 6 comments
Closed

Make vobject python3-compatible #20

prauscher opened this issue Apr 2, 2016 · 6 comments
Assignees

Comments

@prauscher
Copy link
Contributor

althrough vobject is distributed as python3-compatible, it contains lines like https://github.com/eventable/vobject/blob/master/vobject/vcard.py#L137 - str.decode("base64") etc is only supported in python2, so using vobject in a python3-environment especially fails when base64-encoded photos or such are parsed.

@Rondom
Copy link

Rondom commented Apr 29, 2016

@prauscher I think you should use the encoding given in the vcard-file for decoding the quoted-printable encoded fields instead of defaulting to UTF-8. It is available as a variable a few lines further up.

It would be really nice if you could add some test case reproducing the issue to make sure we handle encoded characters correctly on all Python versions

@prauscher
Copy link
Contributor Author

@Rondom the encoding given in the line above is "b" for base64. I currently see no other encoding-variable than "utf-8"

A simple test case should be

BEGIN:VCARD
VERSION:3.0
N:Meister Ede
FN;ENCODING=b:TWVpc3RlciBFZGU=
END:VCARD

the parsed FN should equal to the parsed N - "Meister Ede". You can see that fun even increases when PHOTO is involved ;)

@srepmub
Copy link

srepmub commented Jun 20, 2016

running into similar problem, and above patch seems to fix it. example fragment:

LABEL;WORK;ENCODING=QUOTED-PRINTABLE:100 Waters Edge=0D=0ABaytown, LA 30314=0D=0AUnited States of America

I don't see where to get the encoding either.. it's not in my VCARD test file.

@srepmub
Copy link

srepmub commented Jun 20, 2016

oh, I guess it can be added to the VCARD as follows:

LABEL;HOME;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:42 Plantation St..

according to this:

https://www.imc.org/pdi/vcal-10.txt

it also mentions that the default encoding is ASCII.. so we take CHARSET or default to ASCII..?

@prauscher
Copy link
Contributor Author

Mhh. I'm not sure if defaulting to ASCII is a good thing, as this will break as soon as any ä, ö. ü or related is contained (which would be against the standard probably, but I have seen several iCals without the CHARSET-option). As UTF-8 is ASCII extended, i'd leave UTF-8 as default.

@srepmub
Copy link

srepmub commented Jun 28, 2016

that sounds fine to me.. would you feel like adding some test cases to your patch..? I'd be happy to give that a try as well..

gnoack added a commit to gnoack/avatarlookup that referenced this issue Aug 24, 2016
python-vobject doesn't support Python3:
skarim/vobject#20
esalazar added a commit that referenced this issue Aug 26, 2016
replace str.decode / str.encode for base64 and quoted-printable. should fix #20
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

4 participants