<<< Date Index >>>     <<< Thread Index >>>

Re: Can no longer open an IMAP mailbox



On Wed, Jul 21, 2004 at 06:30:24PM -0400, Brendan Cully wrote:

> This is caused by the new $imap_headers variable. I've attached a
> quick fix, but that variable may need sanitizing later - it's still
> possible to cause a mailbox open to fail with
> set imap_headers=" "
> for example.

Thanks for your patch. I, being too busy to test, have another one.
Sorry, this is against hcache-patched source.

-- 
tamo
--- imap/message.c~     Thu Jul 22 09:20:09 2004
+++ imap/message.c      Thu Jul 22 09:32:23 2004
@@ -90,6 +90,7 @@
   CONTEXT* ctx;
   char buf[LONG_STRING];
   char hdrreq[STRING];
+  char imapheaders[STRING - 160] = ""; /* want_headers + BODY.PEEK[...] */
   FILE *fp;
   char tempfile[_POSIX_PATH_MAX];
   int msgno;
@@ -107,15 +108,17 @@
 
   hc = mutt_hcache_open (HeaderCache, ctx->path);
 
+  if (ImapHeaders && *ImapHeaders)
+    snprintf (imapheaders, sizeof (imapheaders), " %s", ImapHeaders);
   if (mutt_bit_isset (idata->capabilities,IMAP4REV1))
   {
-    snprintf (hdrreq, sizeof (hdrreq), "BODY.PEEK[HEADER.FIELDS (%s %s)]", 
-      want_headers, ImapHeaders);
+    snprintf (hdrreq, sizeof (hdrreq), "BODY.PEEK[HEADER.FIELDS (%s%s)]", 
+      want_headers, imapheaders);
   } 
   else if (mutt_bit_isset (idata->capabilities,IMAP4))
   {
-    snprintf (hdrreq, sizeof (hdrreq), "RFC822.HEADER.LINES (%s %s)", 
-      want_headers, ImapHeaders);
+    snprintf (hdrreq, sizeof (hdrreq), "RFC822.HEADER.LINES (%s%s)", 
+      want_headers, imapheaders);
   }
   else
   {    /* Unable to fetch headers for lower versions */
--- init.h~     Wed Jul 21 06:45:55 2004
+++ init.h      Thu Jul 22 09:35:36 2004
@@ -808,7 +808,7 @@
   ** connecting to IMAP servers.
   */
 # endif
-  { "imap_headers",    DT_STR, R_INDEX, UL &ImapHeaders, UL 0},
+  { "imap_headers",    DT_STR, R_NONE, UL &ImapHeaders, UL ""},
   /*
   ** .pp
   ** Mutt requests these header fields in addition to the default headers