From 62af702935c13e34c5bc17a43d0b991b76de55a6 Mon Sep 17 00:00:00 2001 From: Wouter Verheijen Date: Sat, 20 Apr 2002 08:11:13 +0000 Subject: [PATCH] Bug #571 "mutt should not replicate ">From " headers while bounding", 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 | 5 +++++ mutt.h | 1 + sendlib.c | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/copy.c b/copy.c index 831062a7..514e128e 100644 --- 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 6659bcb0..0381225c 100644 --- 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 */ diff --git a/sendlib.c b/sendlib.c index 6b9b2150..9f5670c2 100644 --- 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); -- 2.50.1