[Dovecot] Pine and prefix - LIST command bug?

Chris Wakelin c.d.wakelin at reading.ac.uk
Thu Mar 31 18:49:47 EEST 2005


On Wed, 30 Mar 2005 18:40:24 +0100 (GMT Daylight Time) Chris Wakelin 
<c.d.wakelin at reading.ac.uk> wrote:

...

> 
> It makes Pine moderately happy at last. It might still be better to 
> respond as it expects to the LIST "" ~/mail/ command.
> 
> Best Wishes,
> Chris
> 

It seems to me that Outlook Express 6 (on XP SP2 plus, I think, all 
recommended patches) is behaving in a similar way to Pine, trying 'LIST 
"" "~/mail"' followed by 'CREATE "" "~/mail/"'

I've tried to implement what may work for 'LIST "" "<namespace>"' :-

--- dovecot-1.0-stable.orig/src/imap/cmd-list.c Fri Mar 18 20:00:44 2005
+++ dovecot-1.0-stable/src/imap/cmd-list.c      Thu Mar 31 16:16:38 2005
@@ -107,7 +107,8 @@
        name_str = t_str_new(256);
        while ((list = mail_storage_mailbox_list_next(ctx->list_ctx)) != NULL) {
                str_truncate(name_str, 0);
-               str_append(name_str, ctx->ns->prefix);
+               if (!(ctx->ns->hidden && ctx->lsub))
+                       str_append(name_str, ctx->ns->prefix);
                str_append(name_str, list->name);

                if (ctx->ns->sep != ctx->ns->real_sep) {
@@ -366,7 +367,8 @@
                   concept which probably no other client uses than Pine.
                   Just try our best to emulate UW-IMAP behavior and hopefully
                   we're fine. */
-               ns = namespace_find(client->namespaces, &ref);
+               const char *ref_copy = t_strdup(ref);
+               ns = namespace_find(client->namespaces, &ref_copy);
                if (ns == NULL) {
                        const char *empty = "";
                        ns = namespace_find(client->namespaces, &empty);
@@ -399,6 +401,28 @@
                }
                client_send_tagline(client, "OK List completed.");
        } else {
+
+               if (*ref == '\0' && !lsub) {
+                       /* LIST "" "something" */
+                       const char *mask_copy = t_strdup(mask);
+                       ns = namespace_find(client->namespaces, &mask_copy);
+                       if (ns == NULL) {
+                               const char *empty = "";
+                               ns = namespace_find(client->namespaces, &empty);
+                       }
+                       if (*ns->prefix != '\0' && *mask_copy == '\0') {
+                               /* namespace, return it */
+                               string_t *str = t_str_new(64);
+                               str_printfa(str, "* LIST (\\Noselect) \"%s\" ",
+                                   ns->sep_str);
+                               imap_quote_append_string(str, ns->prefix,
+                                                        FALSE);
+                               client_send_line(client, str_c(str));
+                               client_send_tagline(client, "OK List completed.");
+                               return TRUE;
+                       }
+               }
+
                ctx = p_new(client->cmd_pool, struct cmd_list_context, 1);
                ctx->ref = ref;
                ctx->mask = mask;

The first two chunks are my fix for the fact that our .mailboxlist 
files have "~/mail/somefolder" in them (probably not generally needed?) 
plus your first suggested fix with my amendment for 'LIST "~/mail/" ""' 
not returning "~/".

The last hunk attempts to return the namespace for any 'LIST "" 
"<namespace>"' command.

It seems to work for me for both PC-Pine and OE6.

I'm surprised nobody else has had this problem. Is no-one else using 
folder prefixes together with hidden namespaces in Dovecot-1.0?

Best Wishes,
Chris

--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--
Christopher Wakelin,                                c.d.wakelin at reading.ac.uk
IT Services Centre, The University of Reading,       Tel: +44 (0)118 378 8439
Whiteknights, Reading, RG6 2AF, UK                   Fax: +44 (0)118 975 3094



More information about the dovecot mailing list