skarim / vobject

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

Unable to parse ics file #68

Closed ddui closed 7 years ago

ddui commented 7 years ago

Im new to python and I am unable to parse the following ics file

If I manually remove the VTIMEZONE section it works. Seems to have something to do with DTSTART

BEGIN:VCALENDAR VERSION:2.0 PRODID:-//TEST//TEST//EN BEGIN:VTIMEZONE TZID:UTC+11 BEGIN:STANDARD DTSTART;VALUE=DATE:20170101 TZNAME:UTC+11 TZOFFSETFROM:+1100 TZOFFSETTO:+1100 END:STANDARD END:VTIMEZONE BEGIN:VEVENT DESCRIPTION:TESTING DTEND;TZID=UTC+11:20170228T233000 DTSTAMP:20170227T064302Z DTSTART;TZID=UTC+11:20170228T230000 RESOURCES:Court 4 SEQUENCE:0 STATUS:Confirmed SUMMARY:TESTIN UID:1961094_636238800000000000 END:VEVENT END:VCALENDAR

wpercy commented 7 years ago

Can you post the entire traceback?

pbiering commented 7 years ago

Here output from my storage checker:

$ /tmp/radicale-storage-check.py /tmp/test.ics 
Analyze file: /tmp/test.ics
Read file: /tmp/test.ics
Parse file contents: /tmp/test.ics
Parse file contents ERROR /tmp/test.ics
Unexpected error: "In transformToNative, unhandled exception on line None: <class 'ValueError'>: unsupported DTSTART parm: VALUE=DATE (<VTIMEZONE| [<TZID{}UTC+11>, <STANDARD| [<DTSTART{'VALUE': ['DATE']}20170101>, <TZNAME{}UTC+11>, <TZOFFSETFROM{}+1100>, <TZOFFSETTO{}+1100>]>]>)"
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 185, in transformToNative
    return self.behavior.transformToNative(self)
  File "/usr/lib/python3.4/site-packages/vobject/icalendar.py", line 997, in transformToNative
    obj.registerTzinfo(obj.tzinfo)
  File "/usr/lib/python3.4/site-packages/vobject/icalendar.py", line 155, in gettzinfo
    return tz.tzical(buffer).get()
  File "/usr/lib/python3.4/site-packages/dateutil/tz.py", line 755, in __init__
    self._parse_rfc(fileobj.read())
  File "/usr/lib/python3.4/site-packages/dateutil/tz.py", line 856, in _parse_rfc
    cache=True)
  File "/usr/lib/python3.4/site-packages/dateutil/rrule.py", line 1371, in __call__
    return self._parse_rfc(s, **kwargs)
  File "/usr/lib/python3.4/site-packages/dateutil/rrule.py", line 1330, in _parse_rfc
    raise ValueError("unsupported DTSTART parm: "+parm)
ValueError: unsupported DTSTART parm: VALUE=DATE

This line is broken

DTSTART;VALUE=DATE:20170101

compared with other ICS files here it looks like such DTSTART is only supported for VEVENT. VTIMEZONE must have format like:

DTSTART:20170101T020000

=> client which created the ICS file is broken.

wpercy commented 7 years ago

Great, thanks @pbiering. Looking at RFC 5545 which defines the VTIMEZONE component, it looks like you are correct in that the DTSTART formatting is wrong.

ddui commented 7 years ago

Hi @wpercy and @pbiering, I looked at icalender.org, using the validator it seems it passes validation (apart from use of the status attribute). https://icalendar.org/validator.html.

I have also found many other uses of DTSTART;VALUE=DATE: on the net. I wonder if it is because it is in the STANDARD section. I will continue investigating to see if this was an old format now depricated.