Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9497:b348632b11e2 HEAD
imap: Fixed listing namespaces with multiple hierarchy separators.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 08 Dec 2009 13:52:14 -0500 |
parents | b7f739902a47 |
children | a9b469e1c8de |
files | src/imap/cmd-list.c |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/cmd-list.c Tue Dec 08 13:35:34 2009 -0500 +++ b/src/imap/cmd-list.c Tue Dec 08 13:52:14 2009 -0500 @@ -251,6 +251,7 @@ enum mailbox_info_flags flags; const char *name; string_t *str; + bool same_ns, ends_with_sep; ctx->cur_ns_send_prefix = FALSE; @@ -262,9 +263,16 @@ return; } + name = ns_get_listed_prefix(ctx); len = strlen(ctx->ns->prefix); + ends_with_sep = ctx->ns->prefix[len-1] == ctx->ns->sep; + + /* we may be listing namespace's parent. in such case we always want to + set the name as nonexistent. */ + same_ns = strcmp(name, ctx->ns->prefix) == 0 || + (strncmp(name, ctx->ns->prefix, len - 1) == 0 && ends_with_sep); if (len == 6 && strncasecmp(ctx->ns->prefix, "INBOX", len-1) == 0 && - ctx->ns->prefix[len-1] == ctx->ns->sep) { + ends_with_sep) { /* INBOX namespace needs to be handled specially. */ if (ctx->inbox_found) { /* we're just now going to send it */ @@ -273,14 +281,13 @@ ctx->inbox_found = TRUE; flags = list_get_inbox_flags(ctx); - } else if (mailbox_list_mailbox(ctx->ns->list, "", &flags) > 0) { + } else if (same_ns && + mailbox_list_mailbox(ctx->ns->list, "", &flags) > 0) { /* mailbox with namespace prefix exists */ } else { flags = MAILBOX_NONEXISTENT; } - name = ns_get_listed_prefix(ctx); - if ((flags & MAILBOX_CHILDREN) == 0) { if (have_children || list_namespace_has_children(ctx)) { flags |= MAILBOX_CHILDREN;