On Fri, 2007-05-11 at 11:50 -0700, Troy Engel wrote: > Session: > a) add $Label1 > b) add $Label2 > c) select INBOX.Drafts > d) select INBOX > e) remove $Label2 > f) remove $Label1 > > Alas, I can't spot where the problem is in the conversation; can I zip > up both logs and send to you? (they're pretty large and contain some > private info)
Looking at the logs, the only difference is that in the working case the $Label2 is returned before $Label1, and in the broken case it's vice versa. You could try if the attached patch helps, but looks like this is a Thunderbird bug if it relies on the order of the returned keywords.
? src/lib-imap/htpasswd Index: src/lib-imap/imap-util.c =================================================================== RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-util.c,v retrieving revision 1.13 diff -u -r1.13 imap-util.c --- src/lib-imap/imap-util.c 26 Dec 2004 09:12:40 -0000 1.13 +++ src/lib-imap/imap-util.c 15 May 2007 17:13:42 -0000 @@ -5,10 +5,23 @@ #include "mail-types.h" #include "imap-util.h" +#include <stdlib.h> + +static int neg_strcasecmp_p(const void *p1, const void *p2) +{ + const char *const *s1 = p1, *const *s2 = p2; + int ret; + + ret = strcasecmp(*s1, *s2); + return ret < 0 ? 1 : + (ret > 1 ? -1 : 0); +} + void imap_write_flags(string_t *dest, enum mail_flags flags, const char *const *keywords) { size_t size; + const char **keywords2; size = str_len(dest); if ((flags & MAIL_ANSWERED) != 0) @@ -25,11 +38,17 @@ str_append(dest, "\\Recent "); if (keywords != NULL) { + unsigned int len = strarray_length(keywords); + + keywords2 = t_new(const char *, len + 1); + memcpy(keywords2, keywords, sizeof(const char *) * len); + qsort(keywords2, len, sizeof(const char *), neg_strcasecmp_p); + /* we have keywords too */ - while (*keywords != NULL) { - str_append(dest, *keywords); + while (*keywords2 != NULL) { + str_append(dest, *keywords2); str_append_c(dest, ' '); - keywords++; + keywords2++; } }
signature.asc
Description: This is a digitally signed message part