[Dovecot] Delimiter of mailbox changes in response to STATUS command...

Chris Wakelin c.d.wakelin at reading.ac.uk
Thu Apr 7 14:33:35 EEST 2005


On Wed, 06 Apr 2005 23:56:13 +0100 Chris Wakelin 
<c.d.wakelin at reading.ac.uk> wrote:

> 
> Anyway here's a session in 1.0-stable where #maildir is my (test) 
> Maildir namespace (I'm using mbox mostly, so that's what I tried before)
> 
> . CREATE "#maildir/test7/test7-2"
> . OK Create completed.
> . LIST "#maildir/test7" "*"
> * LIST (\Unmarked) "/" "INBOX"
> * LIST (\HasNoChildren) "/" "#maildir/test7/test7-2"
> . OK List completed.
> . STATUS "#maildir/test7/test7-2" (UNSEEN)
> * STATUS "test7.test7-2" (UNSEEN 0)
> . OK Status completed.
> 
> So it seems there's a bug in the Maildir code somewhere.

...

> I'll have a look and see if I can fix it, unless Timo or someone else 
> beats me to it :)

OK, here's a patch for 1.0-stable, but it's not very elegant 
(essentially it has to find the namespace for the mailbox a second 
time).

It's based on the code in cmd-list.c (reading RFC2060 it seems to me 
that the STATUS command should return the mailbox name in the same 
format as the LIST command).

I think it should work in 1.0-test66 as well (with slight offsets/fuzz 
in the patch process).

Best Wishes,
Chris

--- dovecot-1.0-stable/src/imap/cmd-status.c.orig       Tue Mar 15 22:00:46 2005
+++ dovecot-1.0-stable/src/imap/cmd-status.c    Thu Apr  7 12:19:19 2005
@@ -5,6 +5,7 @@
 #include "imap-quote.h"
 #include "commands.h"
 #include "imap-sync.h"
+#include "namespace.h"

 /* Returns status items, or -1 if error */
 static enum mailbox_status_items
@@ -84,6 +85,9 @@
        struct mail_storage *storage;
        const char *mailbox;
        string_t *str;
+       struct namespace *ns;
+       const char *mailbox_copy;
+       string_t *name_str;

        /* <mailbox> <status items> */
        if (!client_read_args(client, 2, 0, &args))
@@ -94,6 +98,7 @@
                client_send_command_error(client, "Status items must be list.");
                return TRUE;
        }
+       mailbox_copy = t_strdup(mailbox);

        /* get the items client wants */
        items = get_status_items(client, IMAP_ARG_LIST(&args[1])->args);
@@ -114,7 +119,22 @@

        str = t_str_new(128);
        str_append(str, "* STATUS ");
-        imap_quote_append_string(str, mailbox, FALSE);
+
+       ns = namespace_find(client->namespaces, &mailbox_copy);
+       name_str = t_str_new(128);
+       str_truncate(name_str, 0);
+       str_append(name_str, ns->prefix);
+       str_append(name_str, mailbox_copy);
+       if (ns->sep != ns->real_sep) {
+               char *p = str_c_modifyable(name_str);
+               for (; *p != '\0'; p++) {
+                       if (*p == ns->real_sep)
+                               *p = ns->sep;
+               }
+       }
+       mailbox_copy = str_c(name_str);
+
+       imap_quote_append_string(str, mailbox_copy, FALSE);
        str_append(str, " (");

        if (items & STATUS_MESSAGES)

--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--
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