From 75a8fa3a466fbb86ea2be5ea2afa429f50b27bce Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 31 Aug 2025 10:28:41 +0200 Subject: [PATCH] Workaround broken ICS files with empty RDATE --- CHANGES.rst | 1 + docs/credits.rst | 1 + src/icalendar/cal/component.py | 3 +++ src/icalendar/tests/calendars/empty_RDATE.ics | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 src/icalendar/tests/calendars/empty_RDATE.ics diff --git a/CHANGES.rst b/CHANGES.rst index 3d1540e..9683c33 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -26,6 +26,7 @@ Minor changes: - Add ``new()`` method to ``vCalAddress`` class for consistent API usage. The method supports all RFC 5545 parameters including ``CN``, ``CUTYPE``, ``DELEGATED-FROM``, ``DELEGATED-TO``, ``DIR``, ``LANGUAGE``, ``PARTSTAT``, ``ROLE``, ``RSVP``, and ``SENT-BY``, with automatic ``mailto:`` prefix handling. See `Issue 870 `_. - Refactor ``set_duration`` methods in ``Event`` and ``Todo`` classes to eliminate code duplication by extracting common logic into shared ``set_duration_with_locking()`` function in ``icalendar.attr``. See `Issue 886 `_. - Make coverage submission optional for CI +- Accept and ignore non-standard empty ``RDATE`` fields when parsing ICS files. Breaking changes: diff --git a/docs/credits.rst b/docs/credits.rst index ea5dd85..566e61d 100644 --- a/docs/credits.rst +++ b/docs/credits.rst @@ -39,6 +39,7 @@ icalendar contributors - Russ - `Sashank Bhamidi `_ - Sidnei da Silva +- Simon Ruderich - Stanislav Láznička - Stanislav Ochotnicky - Stefan Schwarzer diff --git a/src/icalendar/cal/component.py b/src/icalendar/cal/component.py index 081f013..e7429d1 100644 --- a/src/icalendar/cal/component.py +++ b/src/icalendar/cal/component.py @@ -379,6 +379,9 @@ class Component(CaselessDict): parsed_components = [ factory(factory.from_ical(vals, params["TZID"])) ] + # Workaround broken ICS files with empty RDATE + elif name == "RDATE" and vals == "": + parsed_components = [] else: parsed_components = [factory(factory.from_ical(vals))] except ValueError as e: diff --git a/src/icalendar/tests/calendars/empty_RDATE.ics b/src/icalendar/tests/calendars/empty_RDATE.ics new file mode 100644 index 0000000..ffc2c95 --- /dev/null +++ b/src/icalendar/tests/calendars/empty_RDATE.ics @@ -0,0 +1,19 @@ +BEGIN:VCALENDAR +PRODID:-//Events Calendar//iCal4j 1.0//EN +CALSCALE:GREGORIAN +VERSION:2.0 +METHOD:PUBLISH +BEGIN:DAYLIGHT +TZNAME:CEST +TZOFFSETFROM:+0100 +TZOFFSETTO:+0200 +DTSTART:19160430T230000 +RDATE: +RDATE: +RDATE: +RDATE: +RDATE: +RDATE: +RDATE: +END:DAYLIGHT +END:VCALENDAR