]> granicus.if.org Git - mutt/commitdiff
Canonicalize IMAP mailboxes before comparing them.
authorBrendan Cully <brendan@kublai.com>
Sun, 11 Jan 2009 02:32:00 +0000 (18:32 -0800)
committerBrendan Cully <brendan@kublai.com>
Sun, 11 Jan 2009 02:32:00 +0000 (18:32 -0800)
imap/imap_private.h
imap/util.c

index 9a861aad81f349df9793a2cba8701d83d89f7eb3..618d8c5316cf35489c7ac228b5c5866de5874ee5 100644 (file)
@@ -272,7 +272,7 @@ int imap_continue (const char* msg, const char* resp);
 void imap_error (const char* where, const char* msg);
 IMAP_DATA* imap_new_idata (void);
 void imap_free_idata (IMAP_DATA** idata);
-char* imap_fix_path (IMAP_DATA* idata, char* mailbox, char* path, 
+char* imap_fix_path (IMAP_DATA* idata, const char* mailbox, char* path, 
   size_t plen);
 void imap_cachepath(IMAP_DATA* idata, const char* mailbox, char* dest,
                     size_t dlen);
index db9e3a76281a523f88b4acd7b4b1e23e2e8ebb77..ebf4237fb15d8bf625205e72aac077f1e6c4ea59 100644 (file)
@@ -266,10 +266,24 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
 /* silly helper for mailbox name string comparisons, because of INBOX */
 int imap_mxcmp (const char* mx1, const char* mx2)
 {
+  char* b1;
+  char* b2;
+  int rc;
+
   if (!ascii_strcasecmp (mx1, "INBOX") && !ascii_strcasecmp (mx2, "INBOX"))
     return 0;
-  
-  return mutt_strcmp (mx1, mx2);
+
+  b1 = safe_malloc (strlen (mx1) + 1);
+  b2 = safe_malloc (strlen (mx2) + 1);
+
+  imap_fix_path (NULL, mx1, b1, strlen (mx1) + 1);
+  imap_fix_path (NULL, mx2, b2, strlen (mx2) + 1);
+
+  rc = mutt_strcmp (b1, b2);
+  FREE (&b1);
+  FREE (&b2);
+
+  return rc;
 }
 
 /* imap_pretty_mailbox: called by mutt_pretty_mailbox to make IMAP paths
@@ -389,7 +403,7 @@ void imap_free_idata (IMAP_DATA** idata)
  * are not required to do this.
  * Moreover, IMAP servers may dislike the path ending with the delimiter.
  */
-char *imap_fix_path (IMAP_DATA *idata, char *mailbox, char *path, 
+char *imap_fix_path (IMAP_DATA *idata, const char *mailbox, char *path, 
     size_t plen)
 {
   int i = 0;