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

Inconsistent behavior when parsing calendars? #399

Open
jacadzaca opened this issue Sep 9, 2022 · 5 comments
Open

Inconsistent behavior when parsing calendars? #399

jacadzaca opened this issue Sep 9, 2022 · 5 comments

Comments

@jacadzaca
Copy link
Collaborator

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

@niccokunzmann
Copy link
Member

niccokunzmann commented Sep 28, 2022

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.

@jacadzaca
Copy link
Collaborator Author

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.

@jacadzaca
Copy link
Collaborator Author

Oh, I think the error is put into the Component.error list, since ignore_exceptions is True for vEvents.

@niccokunzmann
Copy link
Member

@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?

@jacadzaca
Copy link
Collaborator Author

I think that we should either remove the ignore_exception toggle in the future or set it to true for all components by default.

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