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

[PATCH] Mutt doesn't preserve read status flag in imap_append_message()



Hi folks,

I've located and fixed what I believe is a mutt bug in
imap_append_message() that is triggered in a situation such as the
following:

- mutt's inbox is located on an IMAP server, i.e. 
  set spoolfile="{imap_hostname.wherever}INBOX"
- New mail is POP'd ('G') from a POP3 server using mutt, i.e.
  set pop_host = pop_hostname.wherever

In such a situation all mutt releases I've tried up to 1.5.8i
destroy the state of the 'read' message status flag when the new
message is appended to the inbox on the IMAP server.  The new
message is uploaded with the \Seen flag set in the IMAP APPEND
command, and so appears in mutt without the 'N' status character. 
The correct behavior should be to not send the \Seen flag 
if msg->flags.read is not true.

I've attached a rather simple patch to correct the problem to this
message.  It checks the value of msg->flags.read before sending
\Seen to the IMAP server in the APPEND command.  My reading of
RFC3501 indicates that all the flags in the APPEND command are
optional, so this should be perfectly fine.  I've verified that this
solves my problem in my test setup.

This patch seems very much in-line with the recent patch submitted
by Tamotsu Takahashi related to msg->flags.replied and
msg->flags.flagged in this same function that was posted to mutt-dev
earlier this month (as a fall-out of Debian bug #275060).  This
patch appears to have been applied already in mutt v1.5.8i.

Please let me know if there's anything I can do to either fix any
problems with this patch or to attempt to apply this to the mutt
source tree.

Thanks!
Dan Hopper
--- mutt-1.5.8/src/imap/message.c       Sat Feb 12 13:59:59 2005
+++ mutt-1.5.8-dan1/src/imap/message.c  Thu Feb 24 14:57:24 2005
@@ -556,7 +556,8 @@
   rewind (fp);
   
   imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
-  snprintf (buf, sizeof (buf), "APPEND %s (\\Seen%s%s) {%lu}", mbox,
+  snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s) {%lu}", mbox,
+           msg->flags.read    ? " \\Seen"     : "",
            msg->flags.replied ? " \\Answered" : "",
            msg->flags.flagged ? " \\Flagged" : "",
            (unsigned long) len);