From 776d3e6f408ae5c4f903c4ed9e906d84e3e741a1 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 22 Oct 2025 12:09:46 +0300 Subject: [PATCH] lib-storage: Make sure shared INBOX mailbox is always uppercased This fixes issues where if shared/user/INBOX was accessed without uppercasing the INBOX, it wasn't handled consistently. --- src/lib-storage/mail-storage.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 03a1824d55..313854cdea 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -1146,6 +1146,21 @@ struct mailbox *mailbox_alloc(struct mailbox_list *list, const char *vname, errstr = t_strdup(errstr); } + if ((new_list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 && + str_begins(vname, new_list->ns->prefix, &suffix) && + strcasecmp(suffix, "INBOX") == 0 && + strcmp(suffix, "INBOX") != 0) { + /* Accessing INBOX explicitly in a shared namespace - + convert to uppercase. This is done regardless of the + mail_shared_explicit_inbox setting, since even with + "no" adding INBOX to the namespace prefix accesses + the same INBOX. When accessing the shared INBOX + as the namespace prefix, the uppercase INBOX is + appended when getting the storage_name in mailbox + list code. */ + vname = t_strconcat(new_list->ns->prefix, "INBOX", NULL); + } + box = storage->v.mailbox_alloc(storage, new_list, vname, flags); if (open_error != 0) { box->open_error = open_error; -- 2.47.3