]> granicus.if.org Git - mutt/commitdiff
Bug #571 "mutt should not replicate ">From " headers while bounding",
authorWouter Verheijen <wv@xs2mail.com>
Sat, 20 Apr 2002 08:11:13 +0000 (08:11 +0000)
committerWouter Verheijen <wv@xs2mail.com>
Sat, 20 Apr 2002 08:11:13 +0000 (08:11 +0000)
has a patch attached.
Will that patch get in?

Although these lines are not generated by mutt, I would strongly
suggest
to prevent it, because by boucing a mail the MUA should ensure
that the message header is according to the specification.
A ">From " line is not, because of the spaces before a colon.

Because this has such serious consequences (totally unreadable mail)
when a MTA interpretes this line as the beginning of the body (not
unreasonable), I think Mutt should prevent sending this invalid
headerline.

Because the other patch to the bugreport is not really correct IMHO
(because the fieldnames are not limited to alphanumeric chars, RFC2822
3.6.8), I propose another one.

This patch also appends Resent-* to the header, instead of
prepending it. The Resent-Message-Id is however still appended,
because I could not find it; is it added by the MTA instead of by
Mutt?

copy.c
mutt.h
sendlib.c

diff --git a/copy.c b/copy.c
index 831062a7bee76e79f705747bfb4c6c5d8546b112..514e128e54f90c1af7dfad948abe3087109b0342 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -84,6 +84,10 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
            continue;
          from = 1;
        }
+       else if (flags & (CH_NOQFROM) &&
+                       ascii_strncasecmp (">From ", buf, 6) == 0)
+               continue;
+
        else if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n'))
          break; /* end of header */
 
@@ -280,6 +284,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
        CH_UPDATE_LEN   write new Content-Length: and Lines:
        CH_XMIT         ignore Lines: and Content-Length:
        CH_WEED         do header weeding
+       CH_NOQFROM      ignore ">From " line
 
    prefix
        string to use if CH_PREFIX is set
diff --git a/mutt.h b/mutt.h
index 6659bcb057e4b859d0a3141852cbbcdbd3cecd96..0381225cb9ae60ce19cce3d70755b2ddfd9bf520 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -81,6 +81,7 @@
 #define CH_NOLEN       (1<<12) /* don't write Content-Length: and Lines: */
 #define CH_WEED_DELIVERED (1<<13) /* weed eventual Delivered-To headers */
 #define CH_FORCE_FROM  (1<<14) /* give CH_FROM precedence over CH_WEED? */
+#define CH_NOQFROM     (1<<15) /* give CH_FROM precedence over CH_WEED? */
 
 /* flags for mutt_enter_string() */
 #define  M_ALIAS   1      /* do alias "completion" by calling up the alias-menu */
index 6b9b2150be068af4862912586bee13bdf98aa702..9f5670c2ce0c3ae3b383a3ddc4375a9f9d9bd1f5 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -2231,17 +2231,17 @@ static void _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *
   mutt_mktemp (tempfile);
   if ((f = safe_fopen (tempfile, "w")) != NULL)
   {
-    int ch_flags = CH_XMIT | CH_NONEWLINE;
+    int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
     
     if (!option (OPTBOUNCEDELIVERED))
       ch_flags |= CH_WEED_DELIVERED;
     
     fseek (fp, h->offset, 0);
-    mutt_copy_header (fp, h, f, ch_flags, NULL);
     fprintf (f, "Resent-From: %s", resent_from);
     fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof(date)));
     fputs ("Resent-To: ", f);
     mutt_write_address_list (to, f, 11);
+    mutt_copy_header (fp, h, f, ch_flags, NULL);
     fputc ('\n', f);
     mutt_copy_bytes (fp, f, h->content->length);
     fclose (f);