Mon 19 Sep 2005 05:06:03 PM UTC, original submission:
In some cases, the IMAP mailbox backend generates malformed message number sequences, e.g.
g8 STORE 1,3, +FLAGS.SILENT (\Deleted)
Note the trailing comma. This is wrong according to the current version of the relevant IMAP RFC and breaks at least one IMAP server used by a large European IASP. The answer to the above request:
g8 BAD invalid command: "at column 14: parse error, unexpected ICMD_SPACE, expecting ICMD_NUMBER or ICMD_STAR"
I reproduced this by creating a test folder "INBOX.Sprachnachrichten", filling it with four messages and then running the attached program. The bug is present at least in stable 0.6 as well as the version in Debian sid (0.6.90).
We have a workaround, but it doesn't feel right: Remove the trailing comma if it's present. Instead, the sequence should be generated without the trailing comma in the first place.
This is the diff for our workaround:
--- mailutils-0.6/mailbox/imap/mbox.c 2005-01-26 09:16:26.000000000 +0100
+++ mailutils-0.6/mailbox/imap/mbox.c.new 2005-01-26 09:16:18.000000000 +0100
@@ -862,6 +862,17 @@ imap_expunge (mailbox_t mailbox)
free (set);
return 0;
}
+ /removing "," if it is at the end of the list/
+ {
+ char *ctrl = NULL;
+ ctrl = strrchr(set,',');
+ if(ctrl != NULL){
+ if(*(++ctrl) == '\0'){
+ *(--ctrl)='\0';
+ }
+ }
+ }
+
status = imap_writeline (f_imap,
"g%d STORE %s +FLAGS.SILENT (\\Deleted)\r\n",
f_imap->seq++, set);
|