Subject: MIME-Version after Content-Type bug in Pine

From: Mark Crispin <[email-masked]>
Date: Fri, 11 Dec 1992 14:47:59 -0800 (PST)

Thanks to data provided to me by Mike Seibel that demonstrated the bug, I was
able to find a bug in the header parsing code in c-client and fix it.  This
fixes the problem that the fellow in Finland reported.  I have just updated
the mail/imap.tar.Z c-client distribution on ftp.cac.washington.edu to
incorporate this bugfix.

Problem:
 Messages in which the MIME-Version: header occurs as the line immediately
after the Content-Type: header are not recognized and parsed as MIME.  If the
MIME-Version: header occurs later in the header, everything works.

Diagnosis:
 The code to scan the remainder of the header for the string `MIME-Version'
prefixes the search string with a newline to make sure it only sees ones that
start a line.  Unfortunately, it starts the search at the first character of
the next line, instead of at the newline that terminates the current header
line.

Solution:
 Begin the search a character earlier.  In routine rfc822_parse_msg() in
rfc822.c, there is the following code:

      case 'C':			/* possible cc: or Content-<mumble>*/
	if (!strcmp (tmp+1,"C")) rfc822_parse_adrlist (&env->cc,d,host);
	else if ((tmp[1] == 'O') && (tmp[2] == 'N') && (tmp[3] == 'T') &&
		 (tmp[4] == 'E') && (tmp[5] == 'N') && (tmp[6] == 'T') &&
		 (tmp[7] == '-') && body &&
		 (MIMEp || (search (s-1,i,"\012MIME-Version",(long) 13))))
	  rfc822_parse_content_header (body,tmp+8,d);
	break;

Note the ``s-1'' in the call to search().  Version with the bug have ``s''
instead.  Change the ``s'' to ``s-1'' and rebuild.