From: Art Cancro Date: Tue, 27 Feb 2024 03:50:32 +0000 (-0500) Subject: Count nesting level only for comp-filters X-Git-Tag: v999~33 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=59cf6823582d86ea826d3ed9625791da13d6f92b Count nesting level only for comp-filters --- diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index 6f6fde733..80d6627ba 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -19,7 +19,7 @@ enum cr_type { // As we slog our way through the XML we learn what the client is asking for // and build up the contents of this data type. struct cr_params { - int tag_nesting_level; // not needed, just kept for pretty-printing + int comp_filter_nesting_level; enum cr_type report_type; // which RFC4791 section 7 REPORT are we generating StrBuf *Chardata; // XML chardata in between tags is built up here StrBuf *Hrefs; // list of items requested by a `calendar-multiget` REPORT @@ -34,22 +34,9 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { #ifdef DEBUG_XML_PARSE // logging - int i; - char indent[256]; - indent[0] = 0; - 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, " "); - } - for (i = 0; attr[i] != NULL; i += 2) { - syslog(LOG_DEBUG, "%sAttribute '%s' = '%s'", indent, attr[i], attr[i + 1]); + syslog(LOG_DEBUG, "<%s>", el); + for (int i = 0; attr[i] != NULL; i += 2) { + syslog(LOG_DEBUG, "Attribute '%s' = '%s'", attr[i], attr[i + 1]); } // end logging #endif @@ -72,7 +59,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; + crp->filter_nest = crp->comp_filter_nesting_level; } // Handle the filters defined in RFC4791 9.7.1 through 9.7.5 @@ -86,9 +73,13 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { && (crp->filters) // Make sure we actually allocated an array ) { + if (!strcasecmp(el, CAL"comp-filter")) { + ++crp->comp_filter_nesting_level; + } + char newfilter[SIZ]; int a = 0; - int len = snprintf(newfilter, SIZ, "%d|", crp->tag_nesting_level - crp->filter_nest - 1); + int len = snprintf(newfilter, SIZ, "%d|", crp->comp_filter_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 @@ -103,20 +94,18 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { void caldav_xml_end(void *data, const char *el) { struct cr_params *crp = (struct cr_params *) data; - --crp->tag_nesting_level; - #ifdef DEBUG_XML_PARSE // logging int i; - char indent[256]; - indent[0] = 0; - for (i=0; itag_nesting_level; ++i) { - strcat(indent, " "); - } - syslog(LOG_DEBUG, "%s", indent, el); + syslog(LOG_DEBUG, "", el); // end logging #endif + if (!strcasecmp(el, CAL"comp-filter")) { + --crp->comp_filter_nesting_level; + } + + if ((!strcasecmp(el, "DAV::href")) || (!strcasecmp(el, "DAV:href"))) { if (crp->Hrefs == NULL) { // append crp->Chardata to crp->Hrefs crp->Hrefs = NewStrBuf(); @@ -156,12 +145,7 @@ void caldav_xml_chardata(void *data, const XML_Char *s, int len) { string_trim(app); // remove leading/trailing whitespace. ok to mangle it because we've already appended. if (!IsEmptyStr(app)) { int i; - char indent[256]; - indent[0] = 0; - for (i=0; itag_nesting_level; ++i) { - strcat(indent, " "); - } - syslog(LOG_DEBUG, "%s%s", indent, app, len); + syslog(LOG_DEBUG, "%s", app, len); } // end logging #endif diff --git a/webcit-ng/server/webcit.h b/webcit-ng/server/webcit.h index 03efc5e81..4c5c1588a 100644 --- a/webcit-ng/server/webcit.h +++ b/webcit-ng/server/webcit.h @@ -9,7 +9,7 @@ //#define DEBUG_HTTP //#define REQUEST_BODY_TO_STDERR //#define RESPONSE_BODY_TO_STDERR -//#define DEBUG_XML_PARSE +#define DEBUG_XML_PARSE #define SHOW_ME_VAPPEND_PRINTF