collective / icalendar

icalendar parser library for Python

Home Page:https://icalendar.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] RDATE can become None if value is invalid

niccokunzmann opened this issue · comments

Describe the bug

The RDATE is None if it has an invalid PERIOD value in a list and that has an effect on the to_ical fundtion: None is in the ical, making it invalid RFC.

To Reproduce

>>>> import icalendar
>>>> s = b"""BEGIN:VEVENT
.... SUMMARY:RDATE period
.... DTSTART:19961230T020000Z
.... DTEND:19961230T060000Z
.... UID:rdate_period
.... RDATE;VALUE=PERIOD:19970101T180000Z/19970102T070000Z,199709T180000Z/PT5H30M
.... END:VEVENT"""
>>>> event = icalendar.Event.from_ical(s)
>>>> print(event.to_ical().decode())
BEGIN:VEVENT
SUMMARY:RDATE period
DTSTART:19961230T020000Z
DTEND:19961230T060000Z
UID:rdate_period
RDATE:None                <------- error!
END:VEVENT

Expected behavior**

I would expect

  1. That the error is recorded in the event
  2. that this is not None as a value

Environment

  • OS: Ubuntu
  • Python version: 3.9
  • icalendar version: 5.0.0

Additional context

  • I tested it with the latest version pip3 install https://github.com/collective/icalendar.git
  • I attached the ICS source file or there is no ICS source file