]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Don't pass private flag search criteria to the remote server main
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 29 Jul 2026 22:54:36 +0000 (22:54 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 4 Aug 2026 13:10:47 +0000 (13:10 +0000)
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

index 75ca5021f41797bf56079b63a481669d97c698b6..c810dab7cc1f65779e41ec4536c207e7ce1edc40 100644 (file)
@@ -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: