From 0ce74551ac6642b1aceb34b81ea65703cf7cab59 Mon Sep 17 00:00:00 2001 From: Andrew S Erwin Date: Mon, 23 Nov 2026 21:45:22 -0600 Subject: [PATCH] CalDAV: send comp-filter, not comp, in calendar-query (RFC 4791) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sabre/dav (Nextcloud) silently ignores unknown elements inside and 400s with 'The {caldav}filter element is required' when no comp-filter parses — so every calendar REPORT failed against real Nextcloud while the fakes (which ignored REPORT bodies) stayed green. Reproduced against Nextcloud 34.0.3 with a throwaway user: comp -> 400, comp-filter -> 207. fakeCaldav now validates the REPORT body like sabre and returns the same 400, so the integration suite catches this class of bug. --- internal/caldav/client.go | 9 +++++++-- internal/http/caldav_test.go | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/internal/caldav/client.go b/internal/caldav/client.go index f902e35..e311416 100644 --- a/internal/caldav/client.go +++ b/internal/caldav/client.go @@ -228,12 +228,17 @@ func Events(ctx context.Context, conn Conn, calURL string) (*EventResult, error) return out, nil } +// calQueryBody uses comp-filter (RFC 4791 §9.8) — NOT "comp": sabre/dav +// (Nextcloud) silently ignores unknown elements inside , then 400s +// with "The {caldav}filter element is required" when no comp-filter parsed. +// The fakes once ignored REPORT bodies entirely and missed this; fakeCaldav +// now validates the body like sabre does. const calQueryBody = `` + `` + `` + - `` + + `` + `` + - `` + `` // --- PROPFIND plumbing ------------------------------------------------------- diff --git a/internal/http/caldav_test.go b/internal/http/caldav_test.go index 751c0c8..ef3a4e0 100644 --- a/internal/http/caldav_test.go +++ b/internal/http/caldav_test.go @@ -78,6 +78,18 @@ func (f *fakeCaldav) serve(w http.ResponseWriter, r *http.Request) { %s/personal/Personal `, f.root, f.root, f.root) case "REPORT": + // Validate the query body like sabre/dav does: a calendar-query + // without a containing is a 400 ("The + // {caldav}filter element is required"). The old fake ignored the + // body, which let a wrong element name ("comp" instead of + // "comp-filter") ship and fail against real Nextcloud. + raw, _ := io.ReadAll(io.LimitReader(r.Body, 1<<20)) + if !strings.Contains(string(raw), "comp-filter") { + w.Header().Set("Content-Type", "application/xml") + w.WriteHeader(http.StatusBadRequest) + io.WriteString(w, `Sabre\DAV\Exception\BadRequestThe {urn:ietf:params:xml:ns:caldav}filter element is required for this request`) + return + } key := strings.Trim(strings.TrimPrefix(r.URL.Path, f.root+"/"), "/") collection := f.events if key == "personal" {