From 19f9caf5f1cfdbf9eb222a7322e723f35a3f7c68 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 2 Mar 2024 06:59:12 +0100 Subject: [PATCH 1/3] fix for https://github.com/Kozea/Radicale/issues/1316 / Worker thread crashes if a VCALENDAR component contains both VEVENT and VJOURNAL components --- .../tests/static/event_vjournal_vevent.ics | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 radicale/tests/static/event_vjournal_vevent.ics diff --git a/radicale/tests/static/event_vjournal_vevent.ics b/radicale/tests/static/event_vjournal_vevent.ics new file mode 100644 index 000000000..97d1c299f --- /dev/null +++ b/radicale/tests/static/event_vjournal_vevent.ics @@ -0,0 +1,50 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//mozilla.org/Mozilla Thunderbird//EN +BEGIN:VTIMEZONE +TZID:US/Pacific +BEGIN:STANDARD +DTSTART:19671029T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +TZOFFSETFROM:-0700 +TZOFFSETTO:-0800 +TZNAME:PST +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:19870405T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 +TZOFFSETFROM:-0800 +TZOFFSETTO:-0700 +TZNAME:PDT +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +SEQUENCE:0 +DTSTART;TZID=US/Pacific:20021028T140000 +RRULE:FREQ=WEEKLY;COUNT=10 +DTSTAMP:20021028T011706Z +SUMMARY:Coffee with Jason +UID:EC9439B1-FF65-11D6-9973-003065F99D04 +DTEND;TZID=US/Pacific:20021028T150000 +BEGIN:VALARM +TRIGGER;VALUE=DURATION:-P1D +ACTION:DISPLAY +DESCRIPTION:Event reminder\, with comma\nand line feed +END:VALARM +END:VEVENT +BEGIN:VJOURNAL +UID:19970901T130000Z-123405@example.com +DTSTAMP:19970901T130000Z +DTSTART;VALUE=DATE:19970317 +SUMMARY:Staff meeting minutes +DESCRIPTION:1. Staff meeting: Participants include Joe\, + Lisa\, and Bob. Aurora project plans were reviewed. + There is currently no budget reserves for this project. + Lisa will escalate to management. Next meeting on Tuesday.\n + 2. Telephone Conference: ABC Corp. sales representative + called to discuss new printer. Promised to get us a demo by + Friday.\n3. Henry Miller (Handsoff Insurance): Car was + totaled by tree. Is looking into a loaner car. 555-2323 + (tel). +END:VJOURNAL +END:VCALENDAR From b9591ff251cde08b0c9b2e29e7a1281d3e87ef38 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 2 Mar 2024 07:02:34 +0100 Subject: [PATCH 2/3] fix for https://github.com/Kozea/Radicale/issues/1316 / Worker thread crashes if a VCALENDAR component contains both VEVENT and VJOURNAL components --- radicale/item/__init__.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/radicale/item/__init__.py b/radicale/item/__init__.py index b0cef2222..9bfde5cca 100644 --- a/radicale/item/__init__.py +++ b/radicale/item/__init__.py @@ -109,19 +109,17 @@ def check_and_sanitize_items( component_uid = get_uid(component) if component_uid: component_uids.add(component_uid) - component_name = None object_uid = None object_uid_set = False + component_dict = dict(); for component in vobject_item.components(): # https://tools.ietf.org/html/rfc4791#section-4.1 if component.name == "VTIMEZONE": continue - if component_name is None or is_collection: - component_name = component.name - elif component_name != component.name: - raise ValueError("Multiple component types in object: %r, %r" % - (component_name, component.name)) - if component_name not in ("VTODO", "VEVENT", "VJOURNAL"): + if component.name in component_dict: + raise ValueError("Multiple components of same type in object: %r" % (component.name)) + component_dict[component.name] = True + if component.name not in ("VTODO", "VEVENT", "VJOURNAL"): continue component_uid = get_uid(component) if not object_uid_set or is_collection: @@ -130,7 +128,7 @@ def check_and_sanitize_items( if not component_uid: if not is_collection: raise ValueError("%s component without UID in object" % - component_name) + component.name) component_uid = find_available_uid( component_uids.__contains__) component_uids.add(component_uid) @@ -140,11 +138,7 @@ def check_and_sanitize_items( component.add("UID").value = component_uid elif not object_uid or not component_uid: raise ValueError("Multiple %s components without UID in " - "object" % component_name) - elif object_uid != component_uid: - raise ValueError( - "Multiple %s components with different UIDs in object: " - "%r, %r" % (component_name, object_uid, component_uid)) + "object" % component.name) # Workaround for bug in Lightning (Thunderbird) # Rescheduling a single occurrence from a repeating event creates # an event with DTEND and DURATION:PT0S @@ -152,7 +146,7 @@ def check_and_sanitize_items( hasattr(component, "duration") and component.duration.value == timedelta(0)): logger.debug("Quirks: Removing zero duration from %s in " - "object %r", component_name, component_uid) + "object %r", component.name, component_uid) del component.duration # Workaround for Evolution # EXDATE has value DATE even if DTSTART/DTEND is DATE-TIME. From cbbe02bd75885bb982e38afbe95ecb9bd9302bb4 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 2 Mar 2024 07:06:16 +0100 Subject: [PATCH 3/3] remove ; added by accident --- radicale/item/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radicale/item/__init__.py b/radicale/item/__init__.py index 9bfde5cca..e875e9228 100644 --- a/radicale/item/__init__.py +++ b/radicale/item/__init__.py @@ -111,7 +111,7 @@ def check_and_sanitize_items( component_uids.add(component_uid) object_uid = None object_uid_set = False - component_dict = dict(); + component_dict = dict() for component in vobject_item.components(): # https://tools.ietf.org/html/rfc4791#section-4.1 if component.name == "VTIMEZONE":