Skip to content

Commit

Permalink
PROPPATCH: use right namespace prefix in response (#5082)
Browse files Browse the repository at this point in the history
* PROPPATCH: use right namespace prefix in response

* http_dav.c: stylistic changes

---------

Co-authored-by: Ken Murchison <[email protected]>
  • Loading branch information
dilyanpalauzov and ksmurchison authored Oct 11, 2024
1 parent b2a07df commit 0035609
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion imap/http_dav.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ static const struct dav_namespace_t {
{ XML_NS_SYSFLAG, "SF" },
};

#define NUM_KNOWN_NAMESPACES \
(sizeof(known_namespaces) / sizeof(struct dav_namespace_t))

static const struct match_type_t dav_match_types[] = {
{ "contains", MATCH_TYPE_CONTAINS },
{ "equals", MATCH_TYPE_EQUALS },
Expand Down Expand Up @@ -3702,6 +3705,7 @@ static int do_proppatch(struct proppatch_ctx *pctx, xmlNodePtr instr)
entry++);

if (entry->name) {
prop->ns = pctx->ns[entry->ns];
int rights = httpd_myrights(httpd_authstate,
pctx->txn->req_tgt.mbentry);
if (!entry->put) {
Expand Down Expand Up @@ -3738,7 +3742,14 @@ static int do_proppatch(struct proppatch_ctx *pctx, xmlNodePtr instr)
}
else if (pctx->txn->req_tgt.namespace->id != URL_NS_PRINCIPAL) {
/* Write "dead" property */
proppatch_todb(prop, set, pctx, propstat, NULL);
for (size_t i = 0; i < NUM_KNOWN_NAMESPACES; i++) {
if (!strcmp((const char *) prop->ns->href,
known_namespaces[i].href)) {
prop->ns = pctx->ns[i];
break;
}
}
proppatch_todb_internal(prop, set, pctx, propstat, NULL, 1);
}
}
}
Expand Down

0 comments on commit 0035609

Please sign in to comment.