From: Marco Bettini Date: Tue, 22 Mar 2022 10:06:51 +0000 (+0000) Subject: lib-storage: mailbox_match_plugin_exclude() - Consider namespaces while matching X-Git-Tag: 2.4.0~4174 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4da65b330c96c94a67622fe6dd1a4833364166bc;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mailbox_match_plugin_exclude() - Consider namespaces while matching For namespaces with inbox=yes, the match with the rule will be attempted with both the virtual mailbox names and the bare mailbox name. --- diff --git a/src/lib-storage/mailbox-match-plugin.c b/src/lib-storage/mailbox-match-plugin.c index 276d134084..725fd394f3 100644 --- a/src/lib-storage/mailbox-match-plugin.c +++ b/src/lib-storage/mailbox-match-plugin.c @@ -6,6 +6,7 @@ #include "wildcard-match.h" #include "mail-storage-private.h" #include "mailbox-match-plugin.h" +#include "mailbox-list-private.h" struct mailbox_match_plugin { ARRAY_TYPE(const_string) patterns; @@ -45,7 +46,7 @@ bool mailbox_match_plugin_exclude(struct mailbox_match_plugin *match, { const struct mailbox_settings *set; const char *const *special_use; - const char *str; + const char *pattern; if (!array_is_created(&match->patterns)) return FALSE; @@ -55,15 +56,19 @@ bool mailbox_match_plugin_exclude(struct mailbox_match_plugin *match, special_use = set == NULL ? NULL : t_strsplit_spaces(set->special_use, " "); - array_foreach_elem(&match->patterns, str) { - if (str[0] == '\\') { + array_foreach_elem(&match->patterns, pattern) { + if (pattern[0] == '\\') { /* \Special-use flag */ if (special_use != NULL && - str_array_icase_find(special_use, str)) + str_array_icase_find(special_use, pattern)) return TRUE; } else { - /* mailbox name with wildcards */ - if (wildcard_match(box->name, str)) + if (wildcard_match(box->vname, pattern)) + return TRUE; + + /* for namespaces with inbox=yes, try to match also without prefix */ + if (HAS_ALL_BITS(box->list->ns->flags, NAMESPACE_FLAG_INBOX_USER) && + wildcard_match(box->vname + box->list->ns->prefix_len, pattern)) return TRUE; } }