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

Doesn't handle non-standard multi-line values output by Google #108

Open
NickSto opened this issue Mar 16, 2018 · 6 comments
Open

Doesn't handle non-standard multi-line values output by Google #108

NickSto opened this issue Mar 16, 2018 · 6 comments

Comments

@NickSto
Copy link

NickSto commented Mar 16, 2018

This is technically an issue Google Contacts, not vobject, but it's a compatibility issue that I thought the maintainers might be interested in knowing.

I exported my Google Contacts from the Android app into a .vcf file. This file contains several fields where the value extends to multiple lines, but they aren't indented properly. This causes vobject's parser to choke.

It does include many properly-indented values (usually base64-encoded PHOTO;ENCODING=BASE64;JPEG) where the additional lines are indented with a space character.

But there are many values where it's not indented. The ones I've seen are all QUOTED-PRINTABLE-encoded strings.

Is this a known issue? I didn't see anything on an initial search.

@NickSto
Copy link
Author

NickSto commented Mar 16, 2018

Also, just a quick note about another error parsing Google's file:
It choked on a line like this (only thing changed is the number for anonymity):
TEL;:+1-202-867-5309
Not sure yet if this is similarly out-of-spec.

@YuraKursk
Copy link

YuraKursk commented May 5, 2018

TEL;:+1-202-867-5309
This problem can be solved!
But if you add a few phone numbers and TYPEs, the problem will turn out!

v = vobject.vCard()
...
v.add('tel').value = "+1-202-867-5309"
v.tel.type_param = ["CELL", "WORK"]
TEL: +1-202-867-5309
  params for  TEL:
    TYPE ['CELL', 'WORK']

If one phone, then everything is OK!
If you add a second, the first phone is overwritten!

...
v.add('tel').value = "+1-202-000-0000"
v.tel.type_param = ["CELL", "HOME"]
  TEL: +1-202-000-0000
  params for  TEL:
    TYPE ['CELL', 'WORK']
  TEL: 
  params for  TEL:
    TYPE ['CELL', 'HOME']

@NickSto
Copy link
Author

NickSto commented May 11, 2018

@YuraKursk Hi, thanks for your reply!
I don't think I understand exactly what you're explaining. I'm worried about parsing a vcf with a line like
TEL;:+1-202-867-5309
using vobject.readComponents(). Is that what you're talking about?

@YuraKursk
Copy link

YuraKursk commented May 13, 2018

@NickSto

Also, just a quick note about another error parsing Google's file:
It choked on a line like this (only thing changed is the number for anonymity):
TEL;:+1-202-867-5309
Not sure yet if this is similarly out-of-spec.

Write the code itself. The module vobject is raw.
I wrote the code myself, checks the properties of the phone number! If they are not present, then removes SEMI-COLON (ASCII decimal 59).

@YuraKursk
Copy link

YuraKursk commented May 13, 2018

@NickSto, here's the option:

s = 'TEL;:+1-202-867-5309'
i = s.find(':')
if i > 0:
    tag = s[:i]
    data = s[i+1:]
    j = tag.find(';')
    if j > 0:
        typ = tag[j+1:]
        tag = tag[:j]
if len(typ):
    typ = ';' + typ
s = tag + typ + ':' + data
print(s)

TEL:+1-202-867-5309

@NickSto
Copy link
Author

NickSto commented May 14, 2018

@YuraKursk I see, you're suggesting a way to edit the string before giving it to vobject.readComponents()? I've already done that for the multi-line issue I mentioned at the top. Thanks for the algorithm for avoiding the second issue.

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

2 participants