Re: BUG: Cannot delete from IMAP folders



On 2001.07.10 10:44 M . Thielker wrote:
> Hi,
> 
>  just found a bug in balsa (or libmutt?). It is impossible to delete
> messages from IMAP folders when the IMAP path of the folder contains
> spaces.
> Opening messages, storing messages and displaying messages works fine,
> only
> delete fails.
> If the IMAP mailbox is renamed to not contain spaces (on the server), all
> works well.

The problem is in cmd_parse_myrights() (libmutt/imap/command.c), which uses
`s = imap_next_word (s)' to skip over the folder name--but imap_next_word()
defines words by white-space, so it fails when the folder name contains
embedded spaces. Part of the folder name is parsed as the `MYRIGHTS'
response string, with random results. This patch inserts a test for a
quoted name: if it's not quoted, use imap_next_word(), else look for a
closing quote, ignoring embedded spaces (and escaped quotes).

The patch doesn't change imap_next_word(), because it seemed safer to keep
the change local to cmd_parse_myrights(). There may be other places where
imap_next_word() could cause errors when strings contain embedded spaces,
but I haven't seen any. Libmutt's parsing of IMAP responses is pretty
chaotic.
diff -Nur balsa-cvs/libmutt/imap/command.c balsa-temp/libmutt/imap/command.c
--- balsa-cvs/libmutt/imap/command.c	Tue Jul 24 10:51:50 2001
+++ balsa-temp/libmutt/imap/command.c	Fri Jul 27 19:42:42 2001
@@ -510,8 +510,25 @@
   dprint (2, (debugfile, "Handling MYRIGHTS\n"));
 
   s = imap_next_word (s);
-  s = imap_next_word (s);
-
+  /*
+   * Now pointing at folder name. imap_next_word() will skip over it, if
+   * there are no embedded spaces.
+   */
+  if (*s != '\"')
+    s = imap_next_word (s);
+  else {
+    /* skip over '\"': */	  
+    s++;
+    /* find closing '\"': */
+    while (*s && *s != '\"')
+      if (*s++ == '\\')
+	/* skip over escaped char--it might be a '\"': */     
+	s++;      
+    if (*s)
+      /* skip over closing '\"': */	    
+      s++;
+    SKIPWS(s);
+  }
   /* zero out current rights set */
   memset (idata->rights, 0, sizeof (idata->rights));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]