CalDAV: send comp-filter, not comp, in calendar-query (RFC 4791)
sabre/dav (Nextcloud) silently ignores unknown elements inside <filter>
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.
This commit is contained in:
@@ -228,12 +228,17 @@ func Events(ctx context.Context, conn Conn, calURL string) (*EventResult, error)
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calQueryBody uses comp-filter (RFC 4791 §9.8) — NOT "comp": sabre/dav
|
||||||
|
// (Nextcloud) silently ignores unknown elements inside <filter>, 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 = `<?xml version="1.0" encoding="utf-8"?>` +
|
const calQueryBody = `<?xml version="1.0" encoding="utf-8"?>` +
|
||||||
`<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">` +
|
`<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">` +
|
||||||
`<D:prop><D:getetag/><C:calendar-data/></D:prop>` +
|
`<D:prop><D:getetag/><C:calendar-data/></D:prop>` +
|
||||||
`<C:filter><C:comp name="VCALENDAR"><C:comp name="VEVENT">` +
|
`<C:filter><C:comp-filter name="VCALENDAR"><C:comp-filter name="VEVENT">` +
|
||||||
`<C:time-range start="%s" end="%s"/>` +
|
`<C:time-range start="%s" end="%s"/>` +
|
||||||
`</C:comp></C:comp></C:filter></C:calendar-query>`
|
`</C:comp-filter></C:comp-filter></C:filter></C:calendar-query>`
|
||||||
|
|
||||||
// --- PROPFIND plumbing -------------------------------------------------------
|
// --- PROPFIND plumbing -------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,18 @@ func (f *fakeCaldav) serve(w http.ResponseWriter, r *http.Request) {
|
|||||||
<response><href>%s/personal/</href><propstat><prop xmlns:C="urn:ietf:params:xml:ns:caldav"><resourcetype><C:calendar/></resourcetype><displayname>Personal</displayname></prop></propstat></response>
|
<response><href>%s/personal/</href><propstat><prop xmlns:C="urn:ietf:params:xml:ns:caldav"><resourcetype><C:calendar/></resourcetype><displayname>Personal</displayname></prop></propstat></response>
|
||||||
</multistatus>`, f.root, f.root, f.root)
|
</multistatus>`, f.root, f.root, f.root)
|
||||||
case "REPORT":
|
case "REPORT":
|
||||||
|
// Validate the query body like sabre/dav does: a calendar-query
|
||||||
|
// without a <filter> containing <comp-filter> 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, `<?xml version="1.0"?><d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><s:exception>Sabre\DAV\Exception\BadRequest</s:exception><s:message>The {urn:ietf:params:xml:ns:caldav}filter element is required for this request</s:message></d:error>`)
|
||||||
|
return
|
||||||
|
}
|
||||||
key := strings.Trim(strings.TrimPrefix(r.URL.Path, f.root+"/"), "/")
|
key := strings.Trim(strings.TrimPrefix(r.URL.Path, f.root+"/"), "/")
|
||||||
collection := f.events
|
collection := f.events
|
||||||
if key == "personal" {
|
if key == "personal" {
|
||||||
|
|||||||
Reference in New Issue
Block a user