Hi,

When mutt parses a header line that includes a space in the header name field,
it treats this line and all following lines as body text.

This has the unwanted effect of moving genuine headers into the body of the
message.

Although the ASCII space character is not usually permitted in a header name
field, RFC 5322 defines as an 'obsolete syntax' headers with any amount of WSP
characters immediately before the colon.

Parsing them correctly is actually a MUST in RFC 5322, (although generation of
headers in this obsolete format is a MUST NOT in the same RFC 5322).

The code responsible for this in mutt is in parse.c, function
mutt_read_rfc822_header() and seems to have been this way in every mutt
version released.

So maybe this is actually a feature and not a bug, perhaps a work-around for
compatibility with broken muas in use at the time.

In any case, if it is now considered a bug then something like the following
would fix it, although I'm not really familiar with the mutt codebase so you
might prefer a different approach.

--- parse.c.dist        Fri Aug 18 00:03:18 2023
+++ parse.c     Sat Dec  2 09:14:46 2023
@@ -1596,7 +1596,7 @@
   while ((loc = ftello (f)),
          *(line = mutt_read_rfc822_line (f, line, &linelen)) != 0)
   {
-    if ((p = strpbrk (line, ": \t")) == NULL || *p != ':')
+    if ((p = strpbrk (line, ": \t")) == NULL || (*p != ':' && *(p + strspn(p, 
" \t")) != ':'))
     {
       char return_path[LONG_STRING];
       time_t t;

Reply via email to