Inconsistent behavior when parsing calendars?
jacadzaca opened this issue · comments
This snippet:
from icalendar import Calendar
with open('some_calendar.ics') as f:
calendar = Calendar.from_ics(f.read())
print(calendar.to_ical())
when passed this broken calendar:
BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART:20140401T000000Z
DTEND:20140401T010000Z
DTSTAMP:20140401T000000Z
SUMMARY:Broken Eevnt
CLASS:PUBLIC
STATUS:CONFIRMED
TRANSP:OPAQUE
END:VEVENT
X
END:VCALENDAR
outputs ValueError: Content line could not be parsed into parts: 'X': Invalid content line
but when it's passed this broken calendar:
BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20150905T090000Z
DTEND:20150905T100000Z
UID:123
X-APPLE-RADIUS=49.91307046514149
END:VEVENT
END:VCALENDAR
outputs b'BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20150905T090000Z\r\nDTEND:20150905T100000Z\r\nUID:123\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n'
icalendar should either always throw an exception on broken calendar or always skip the broken property.
icalendar is from master branch
Related tests: test_issue_168 and test_issue_104
Hm. I can not see where the second example is invalid. Can you point out the line?
I would say example 1 is against the syntax.
I'd say that X-APPLE-RADIUS
is wrongly defined since in the RFC a =
doesn't seem to be equivalent to a :
(contentline = name *(";" param ) ":" value CRLF). Both X-APPLE-RADIUS
and X
are wrong, but their handling is different - icalendar raises an error on X
but just skips the X-APPLE-RADIUS
(note that it's not present in the output). Also, the validator dosen't throw an error on neither the X
or the X-APPLE-RADIUS
line.
Oh, I think the error is put into the Component.error
list, since ignore_exceptions
is True for vEvents.
@jacadzaca Do you have a suggestion for this issue? Do you think this is re-solved as the understanding of the icalendar module grew for us?
I think that we should either remove the ignore_exception
toggle in the future or set it to true for all components by default.