From 83a7853405d560438eb732b4a179224ef49ad7eb Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 8 Jul 2025 16:09:28 +0100 Subject: [PATCH] add test_report_with_max_occur and fix vevent count issue found Signed-off-by: David Greaves --- radicale/app/report.py | 2 +- .../tests/static/event_multiple_too_many.ics | 100 ++++++++++++++++++ radicale/tests/test_expand.py | 17 ++- 3 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 radicale/tests/static/event_multiple_too_many.ics diff --git a/radicale/app/report.py b/radicale/app/report.py index 4c56adb1..26ad1722 100644 --- a/radicale/app/report.py +++ b/radicale/app/report.py @@ -310,7 +310,7 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element], found_props.append(expanded_element) else: found_props.append(element) - n_vevents += 1 + n_vevents += len(item.vobject_item.vevent_list) # Avoid DoS with too many events if max_occurrence and n_vevents > max_occurrence: raise ValueError("REPORT occurrences limit of {} hit" diff --git a/radicale/tests/static/event_multiple_too_many.ics b/radicale/tests/static/event_multiple_too_many.ics new file mode 100644 index 00000000..4047ef06 --- /dev/null +++ b/radicale/tests/static/event_multiple_too_many.ics @@ -0,0 +1,100 @@ +BEGIN:VCALENDAR +PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN +VERSION:2.0 +BEGIN:VTIMEZONE +TZID:Europe/Paris +X-LIC-LOCATION:Europe/Paris +BEGIN:DAYLIGHT +TZOFFSETFROM:+0100 +TZOFFSETTO:+0200 +TZNAME:CEST +DTSTART:19700329T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 +END:DAYLIGHT +BEGIN:STANDARD +TZOFFSETFROM:+0200 +TZOFFSETTO:+0100 +TZNAME:CET +DTSTART:19701025T030000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +UID:event_multiple_too_many +SUMMARY:Event +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many1 +SUMMARY:Event1 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many2 +SUMMARY:Event2 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many3 +SUMMARY:Event3 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many4 +SUMMARY:Event4 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many5 +SUMMARY:Event5 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many6 +SUMMARY:Event6 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many7 +SUMMARY:Event7 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many8 +SUMMARY:Event8 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many9 +SUMMARY:Event9 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many10 +SUMMARY:Event10 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VEVENT +UID:event_multiple_too_many11 +SUMMARY:Event11 +DTSTART;TZID=Europe/Paris:20130901T190000 +DTEND;TZID=Europe/Paris:20130901T200000 +END:VEVENT +BEGIN:VTODO +UID:todo +DTSTART;TZID=Europe/Paris:20130901T220000 +DURATION:PT1H +SUMMARY:Todo +END:VTODO +END:VCALENDAR diff --git a/radicale/tests/test_expand.py b/radicale/tests/test_expand.py index 3b353556..bedc9d12 100644 --- a/radicale/tests/test_expand.py +++ b/radicale/tests/test_expand.py @@ -203,7 +203,7 @@ permissions: RrWw""") assert "RRULE" in element.text - status, headers, answer = self.request( + status, _, _ = self.request( "REPORT", "/calendar.ics/", self._req_with_expand(expected_uid, start, end), check=check) @@ -332,3 +332,18 @@ permissions: RrWw""") "20060501T000000Z", check=400 ) + + def test_report_with_max_occur(self) -> None: + """Test report with too many vevents""" + self.configure({"reporting": {"max_freebusy_occurrence": 10}}) + + uid = "event_multiple_too_many" + start = "20130901T000000Z" + end = "20130902T000000Z" + check = 400 + + status, responses = self.report("/calendar.ics/", + self._req_without_expand(uid, start, end), + check=check) + assert len(responses) == 0 + assert status == check