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

Re: bug: incorrect conversion from MMDF to mbox



On Saturday, 23 July 2005 at 21:04, Brendan Cully wrote:
> On Tuesday, 31 May 2005 at 21:34, TAKAHASHI Tamotsu wrote:
> > * Wed May 11 2005 William Lovas <wlovas@xxxxxxxxxxxxxxxx>
> > > I've encountered a bug in mutt versions 1.4i and 1.5.6i: if you load an
> > > MMDF mailbox with no "From ..." lines and try to save the messages to an
> > > mbox mailbox -- i.e. with mbox_type=mbox -- mutt will create invalid mbox
> > > mailboxes by not inserting any "From ..." lines.
> > 
> > As MMDF doesn't require "From " line, mutt should use M_ADD_FROM flag:
> > 
> > +++ copy.c  Tue May 31 21:24:55 2005
> > @@ -704,7 +704,7 @@
> >    MESSAGE *msg;
> >    int r;
> >  
> > -  if ((msg = mx_open_new_message (dest, hdr, (src->magic == M_MBOX || 
> > src->magic == M_MMDF) ? 0 : M_ADD_FROM)) == NULL)
> > +  if ((msg = mx_open_new_message (dest, hdr, (src->magic == M_MBOX) ? 0 : 
> > M_ADD_FROM)) == NULL)
> >      return -1;
> >    if (dest->magic == M_MBOX || dest->magic == M_MMDF)
> >      chflags |= CH_FROM | CH_FORCE_FROM;
> 
> Won't this produce two from lines in the case that the MMDF folder
> DOES have a From line? In particular, I wonder whether copying
> messages back and forth between an mbox and mmdf folder might produce
> different messages.

The attached patch should work better.
Index: copy.c
===================================================================
RCS file: /home/roessler/cvs/mutt/copy.c,v
retrieving revision 3.17
diff -u -p -r3.17 copy.c
--- copy.c      3 Feb 2005 17:01:42 -0000       3.17
+++ copy.c      24 Jul 2005 07:54:21 -0000
@@ -701,10 +701,15 @@ int
 _mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
                      BODY *body, int flags, int chflags)
 {
+  char buf[STRING];
   MESSAGE *msg;
   int r;
 
-  if ((msg = mx_open_new_message (dest, hdr, (src->magic == M_MBOX || 
src->magic == M_MMDF) ? 0 : M_ADD_FROM)) == NULL)
+  fseek(fpin, hdr->offset, 0);
+  if (fgets (buf, sizeof (buf), fpin) == NULL)
+    return -1;
+  
+  if ((msg = mx_open_new_message (dest, hdr, is_from (buf, NULL, 0, NULL) ? 0 
: M_ADD_FROM)) == NULL)
     return -1;
   if (dest->magic == M_MBOX || dest->magic == M_MMDF)
     chflags |= CH_FROM | CH_FORCE_FROM;

Attachment: pgpvadyg0CROo.pgp
Description: PGP signature