Commit62f8d16dRecorded17 Mar 2026Repositorysigil-caldav

Filter non-recurring events by date range in CalDAV recurrence expansion

Message

When a recurring event's iCalendar data contains exception instances (VEVENT entries with RECURRENCE-ID but no RRULE), they were being included in results regardless of the queried date range. Now all non-recurring events are filtered by start/end before inclusion.

Changed
 src/sigil/caldav/event.sgl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Diff
src/sigil/caldav/event.sglmodified
@@ -90,7 +90,9 @@
90
(loop (cdr remaining) (append (reverse parsed) events)))
91
(loop (cdr remaining) events))))))
92
93
;; Expand recurrence for all events that have RRULE
+93
;; Expand recurrence for all events that have RRULE.
+94
;; Non-recurring events (including exception instances with RECURRENCE-ID)
+95
;; are filtered by the date range to avoid returning out-of-range entries.
96
(define (expand-all-events events start end)
97
(let loop ((remaining events) (result '()))
98
(if (null? remaining)
@@ -101,7 +103,13 @@
103
(append (reverse (ical-expand-recurrence ev
104
start: start end: end))
105
result))
104
(loop (cdr remaining) (cons ev result)))))))
+106
;; Non-recurring: include only if within range
+107
(let ((ev-start (ical-event-dtstart ev)))
+108
(if (and ev-start
+109
(or (not start) (>= ev-start start))
+110
(or (not end) (< ev-start end)))
+111
(loop (cdr remaining) (cons ev result))
+112
(loop (cdr remaining) result))))))))
113
114
115
;; ============================================================