From 9053e2d882352050a3fd443ccfbaf321a0222b93 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 21 Feb 2024 20:56:43 -0500 Subject: [PATCH] Completed the first two filter tests. comp-filter on the root element are the first two tests. Yes, these are ridiculously easy, but hopefully it gets the design pattern started and we can move on from there. --- webcit-ng/server/caldav_reports.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index d93088076..ef9072829 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -296,10 +296,27 @@ int caldav_apply_filters(void *cal, Array *filters) { // Handle the individual filters defined in RFC4791 9.7.1 through 9.7.5 if (!strcasecmp(t[1], "comp-filter")) { // RFC4791 9.7.1 - filter by component - syslog(LOG_DEBUG, "component filter at level %d FIXME not implemented yet", level); - if (icalcomponent_isa_component(cal)) { - // yes this is a component + syslog(LOG_DEBUG, "component filter at level %d", level); + + // Root element is NOT a component, but the root filter is "comp-filter" -- reject! + if ( (!icalcomponent_isa_component(cal)) && (level == 0) ) { + syslog(LOG_DEBUG, "caldav: root element is not a component, rejecting"); + return(0); } + + // Root element IS a component and the root filter is "comp-filter" -- see if it matches the requested type + if ( (icalcomponent_isa_component(cal)) + && (level == 0) + && (!strcasecmp(t[2], "name")) + ) { + if (icalcomponent_isa(cal) != icalcomponent_string_to_kind(t[3]) ) { + syslog(LOG_DEBUG, "caldav: root component is <%s>, looking for <%s>, rejecting", + icalcomponent_kind_to_string(icalcomponent_isa(cal)), t[3] + ); + return(0); + } + } + } else if (!strcasecmp(t[1], "prop-filter")) { // RFC4791 9.7.2 - filter by property -- 2.30.2