dovecot-2.0: imap: Fixed listing namespaces with multiple hierar...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Dec 8 20:51:55 EET 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/3a1f6c1a8485
changeset: 10427:3a1f6c1a8485
user: Timo Sirainen <tss at iki.fi>
date: Tue Dec 08 13:51:49 2009 -0500
description:
imap: Fixed listing namespaces with multiple hierarchy separators.
diffstat:
1 file changed, 11 insertions(+), 4 deletions(-)
src/imap/cmd-list.c | 15 +++++++++++----
diffs (45 lines):
diff -r 05cfc267aa3d -r 3a1f6c1a8485 src/imap/cmd-list.c
--- a/src/imap/cmd-list.c Tue Dec 08 13:33:27 2009 -0500
+++ b/src/imap/cmd-list.c Tue Dec 08 13:51:49 2009 -0500
@@ -251,6 +251,7 @@ list_namespace_send_prefix(struct cmd_li
enum mailbox_info_flags flags;
const char *name;
string_t *str;
+ bool same_ns, ends_with_sep;
ctx->cur_ns_send_prefix = FALSE;
@@ -261,9 +262,16 @@ list_namespace_send_prefix(struct cmd_li
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 */
@@ -272,13 +280,12 @@ list_namespace_send_prefix(struct cmd_li
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)) {
More information about the dovecot-cvs
mailing list