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" {