From: Timo Sirainen Date: Sat, 17 Feb 2018 20:25:20 +0000 (+0200) Subject: lib-storage: Add and use MAILBOX_LIST_PROP_NO_INTERNAL_NAMES X-Git-Tag: 2.3.9~2205 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2a86a88fb41f4777a937dec3b2d54dedd47ed6cc;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Add and use MAILBOX_LIST_PROP_NO_INTERNAL_NAMES Use it to replace Maildir++ check to see if mailbox_list.is_internal_name() is wanted to be used. --- diff --git a/src/lib-storage/list/mailbox-list-maildir.c b/src/lib-storage/list/mailbox-list-maildir.c index 9077728980..20e7e945f3 100644 --- a/src/lib-storage/list/mailbox-list-maildir.c +++ b/src/lib-storage/list/mailbox-list-maildir.c @@ -491,7 +491,8 @@ struct mailbox_list maildir_mailbox_list = { .name = MAILBOX_LIST_NAME_MAILDIRPLUSPLUS, .props = MAILBOX_LIST_PROP_NO_MAILDIR_NAME | MAILBOX_LIST_PROP_NO_ALT_DIR | - MAILBOX_LIST_PROP_NO_NOSELECT, + MAILBOX_LIST_PROP_NO_NOSELECT | + MAILBOX_LIST_PROP_NO_INTERNAL_NAMES, .mailbox_name_max_length = MAILBOX_LIST_NAME_MAX_LENGTH, .v = { @@ -519,7 +520,8 @@ struct mailbox_list imapdir_mailbox_list = { .name = MAILBOX_LIST_NAME_IMAPDIR, .props = MAILBOX_LIST_PROP_NO_MAILDIR_NAME | MAILBOX_LIST_PROP_NO_ALT_DIR | - MAILBOX_LIST_PROP_NO_NOSELECT, + MAILBOX_LIST_PROP_NO_NOSELECT | + MAILBOX_LIST_PROP_NO_INTERNAL_NAMES, .mailbox_name_max_length = MAILBOX_LIST_NAME_MAX_LENGTH, .v = { diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c index c0121827dd..e1a7ab2ef1 100644 --- a/src/lib-storage/mailbox-list.c +++ b/src/lib-storage/mailbox-list.c @@ -1319,11 +1319,10 @@ mailbox_list_is_valid_fs_name(struct mailbox_list *list, const char *name, some mailbox formats have reserved directory names, such as Maildir's cur/new/tmp. if any of those would conflict with the - mailbox directory name, it's not valid. maildir++ is kludged here as - a special case because all of its mailbox dirs begin with "." */ + mailbox directory name, it's not valid. */ allow_internal_dirs = list->v.is_internal_name == NULL || *list->set.maildir_name != '\0' || - strcmp(list->name, MAILBOX_LIST_NAME_MAILDIRPLUSPLUS) == 0; + (list->props & MAILBOX_LIST_PROP_NO_INTERNAL_NAMES) != 0; T_BEGIN { const char *const *names; diff --git a/src/lib-storage/mailbox-list.h b/src/lib-storage/mailbox-list.h index eff2e4de13..ef476ae00c 100644 --- a/src/lib-storage/mailbox-list.h +++ b/src/lib-storage/mailbox-list.h @@ -29,6 +29,10 @@ enum mailbox_list_properties { MAILBOX_LIST_PROP_AUTOCREATE_DIRS = 0x10, /* Explicitly disable mailbox list index */ MAILBOX_LIST_PROP_NO_LIST_INDEX = 0x20, + /* Disable checking mailbox_list.is_internal_name(). The layout is + implemented in a way that there aren't any such reserved internal + names. For example Maildir++ prefixes all mailboxes with "." */ + MAILBOX_LIST_PROP_NO_INTERNAL_NAMES = 0x40, }; enum mailbox_list_flags {