From 2262587ffce0e5e41fa8daa09449c3cc0f7de3d1 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 21 Feb 2024 00:08:57 -0500 Subject: [PATCH] I wish much death and suffering to Cyrus Daboo, Lisa M. Dusseault, and Bernard Desruisseaux. They must be punished severely for creating CalDAV. --- webcit-ng/server/caldav_reports.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index 9c0fe32a0..31fe712ba 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -25,6 +25,7 @@ struct cr_params { StrBuf *Chardata; // XML chardata in between tags is built up here StrBuf *Hrefs; // list of items requested by a `calendar-multiget` REPORT Array *filters; // If the query contains a FILTER stanza, the filter criteria are populated here + int filter_nest; // tag nesting level where a FILTER stanza begins }; @@ -37,11 +38,13 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { int i; char indent[256]; indent[0] = 0; - lor (i=0; itag_nesting_level; ++i) { + for (i=0; itag_nesting_level; ++i) { strcat(indent, " "); } syslog(LOG_DEBUG, "%s<%s>", indent, el); +#endif ++crp->tag_nesting_level; +#ifdef DEBUG_XML_PARSE indent[0] = 0; for (i=0; itag_nesting_level; ++i) { strcat(indent, " "); @@ -70,6 +73,7 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { // RFC4791 9.7 create a filter array if this query contains a "filter" stanza else if (!strcasecmp(el, CAL"filter")) { crp->filters = array_new(SIZ); + crp->filter_nest = crp->tag_nesting_level; } // Handle the filters defined in RFC4791 9.7.1 through 9.7.5 @@ -81,9 +85,11 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { ) && (crp->filters) // Make sure we actually allocated an array ) { + char newfilter[SIZ]; int a = 0; - int len = snprintf(newfilter, SIZ, &el[CALLEN]); // strip off the namespace for our purposes + int len = snprintf(newfilter, SIZ, "%d|", crp->tag_nesting_level - crp->filter_nest - 1); + len += snprintf(&newfilter[len], SIZ-len, "%s", &el[CALLEN]); // filter name without the namespace while (attr[a]) { len += snprintf(&newfilter[len], SIZ-len, "|%s", attr[a++]); // now save the attributes } @@ -293,7 +299,7 @@ int caldav_apply_one_filter(void *cal, char *filter) { // Handle the individual filters defined in RFC4791 9.7.1 through 9.7.5 - if (!strcasecmp(t[0], "comp-filter")) { // RFC4791 9.7.1 - filter by component + if (!strcasecmp(t[1], "comp-filter")) { // RFC4791 9.7.1 - filter by component syslog(LOG_DEBUG, "component filter FIXME not implemented yet"); if (icalcomponent_isa_component(cal)) { syslog(LOG_DEBUG, "\033[32m yes this is a component \033[0m"); @@ -303,19 +309,19 @@ int caldav_apply_one_filter(void *cal, char *filter) { } } - else if (!strcasecmp(t[0], "prop-filter")) { // RFC4791 9.7.2 - filter by property + else if (!strcasecmp(t[1], "prop-filter")) { // RFC4791 9.7.2 - filter by property syslog(LOG_DEBUG, "property filter FIXME not implemented yet"); } - else if (!strcasecmp(t[0], "param-filter")) { // RFC4791 9.7.3 - filter by parameter + else if (!strcasecmp(t[1], "param-filter")) { // RFC4791 9.7.3 - filter by parameter syslog(LOG_DEBUG, "parameter filter FIXME not implemented yet"); } - else if (!strcasecmp(t[0], "is-not-defined")) { // RFC4791 9.7.4 + else if (!strcasecmp(t[1], "is-not-defined")) { // RFC4791 9.7.4 syslog(LOG_DEBUG, "is-not-defined filter FIXME not implemented yet"); } - else if (!strcasecmp(t[0], "text-match")) { // RFC4791 9.7.5 + else if (!strcasecmp(t[1], "text-match")) { // RFC4791 9.7.5 syslog(LOG_DEBUG, "text match filter FIXME not implemented yet"); } -- 2.30.2