skarim / vobject

A full-featured Python package for parsing and creating iCalendar and vCard files
http://eventable.github.io/vobject/
254 stars 90 forks source link

Fails to parse multiline PHOTO field #158

Closed madduck closed 3 years ago

madduck commented 3 years ago

Using the attached test script, as well as the test vCard, which is a compliant vCard with an encoded PHOTO, the following error is generated when readComponents is called:

% ./vobject_test.py test_person.vcf
Traceback (most recent call last):
  File "/tmp/./vobject_test.py", line 15, in <module>
    for card in vobject.readComponents(buffer, validate=True):
  File "/usr/lib/python3/dist-packages/vobject/base.py", line 1101, in readComponents
    vline = textLineToContentLine(line, n)
  File "/usr/lib/python3/dist-packages/vobject/base.py", line 925, in textLineToContentLine
    return ContentLine(*parseLine(text, n), **{'encoded': True,
  File "/usr/lib/python3/dist-packages/vobject/base.py", line 813, in parseLine
    raise ParseError("Failed to parse line: {0!s}".format(line), lineNumber)
vobject.base.ParseError: At line 31: Failed to parse line: AAAHABIBAwABAAAAAQAAABoBBQABAAAAYgAAABsBBQABAAAAagAAACgBAwABAAAAAgAAADEBAg

It seems that vobject is failing to properly handle line continuations, which seems weird, but it's the best explanation I could come up with. vobject_fails_parse_photo.zip

madduck commented 3 years ago

I am sorry, nevermind. I should not join all those lines using '\n' ;)