From f881d213d80e23e5b1f8717a5d389bb8a38cf673 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 29 Jul 2026 22:54:36 +0000 Subject: [PATCH] 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. --- src/lib-storage/index/imapc/imapc-search.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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: -- 2.47.3