From: Timo Sirainen Date: Wed, 29 Jul 2026 22:54:36 +0000 (+0000) Subject: imapc: Don't pass private flag search criteria to the remote server X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;p=thirdparty%2Fdovecot%2Fcore.git imapc: Don't pass private flag search criteria to the remote server With private indexes the \Seen flag is stored locally, so the remote server doesn't know its current value. Searching e.g. "SEEN SUBJECT foo" passed the SEEN criteria to the remote server, which evaluated it against a flag that isn't authoritative, and the result was then used as-is. Leave such flag args out of the remote query and evaluate them locally. --- diff --git a/src/lib-storage/index/imapc/imapc-search.c b/src/lib-storage/index/imapc/imapc-search.c index 75ca5021f4..c810dab7cc 100644 --- a/src/lib-storage/index/imapc/imapc-search.c +++ b/src/lib-storage/index/imapc/imapc-search.c @@ -214,10 +214,18 @@ imapc_build_search_query_arg(struct imapc_mailbox *mbox, supported. */ arg2.value.date_type = MAIL_SEARCH_DATE_TYPE_RECEIVED; } + return mail_search_arg_to_imap(str, arg, FALSE, &error); + case SEARCH_FLAGS: + if ((arg->value.flags & + mailbox_get_private_flags_mask(&mbox->box)) != 0) { + /* The flag is stored in the private index, which the + remote server doesn't know about. Evaluate it + locally. */ + return FALSE; + } /* fall through */ case SEARCH_ALL: case SEARCH_UIDSET: - case SEARCH_FLAGS: case SEARCH_KEYWORDS: case SEARCH_SMALLER: case SEARCH_LARGER: