Mercurial > dovecot > core-2.2
changeset 17817:ad16c74f4f36
lib-storage: SEARCH_MAILBOX* value is now also compared to to the (virtual) mailbox name.
This fixes for example "doveadm fetch uid mailbox virtual/all"
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 16 Sep 2014 15:43:42 +0300 |
parents | 8c2cb7d01a78 |
children | 4374e04f6aae |
files | src/lib-storage/index/index-search.c |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-search.c Tue Sep 16 15:23:51 2014 +0300 +++ b/src/lib-storage/index/index-search.c Tue Sep 16 15:43:42 2014 +0300 @@ -239,10 +239,19 @@ static int search_arg_match_mailbox(struct index_search_context *ctx, struct mail_search_arg *arg) { + struct mailbox *box = ctx->cur_mail->box; const char *str; switch (arg->type) { case SEARCH_MAILBOX: + /* first try to match the mailbox name itself. this is + important when using "mailbox virtual/foo" parameter foin + doveadm's search query, otherwise we can never fetch + anything with doveadm from virtual mailboxes because the + mailbox parameter is compared to the mail's backend + mailbox. */ + if (strcmp(box->vname, arg->value.str) == 0) + return 1; if (mail_get_special(ctx->cur_mail, MAIL_FETCH_MAILBOX_NAME, &str) < 0) return -1; @@ -251,6 +260,8 @@ return strcasecmp(arg->value.str, "INBOX") == 0; return strcmp(str, arg->value.str) == 0; case SEARCH_MAILBOX_GLOB: + if (imap_match(arg->value.mailbox_glob, box->vname) == IMAP_MATCH_YES) + return 1; if (mail_get_special(ctx->cur_mail, MAIL_FETCH_MAILBOX_NAME, &str) < 0) return -1;