i've recently started getting messages with multiple MIME-Version
headers.  they all say "1.0", of course.

mhparse() verifies the first such header.  it will warn if the value's
not 1.0 ("unknown value"), but will proceed in any case.  any
subsequent such header generates a "has multiple fields" warning, but
is then ignored _without_ verification:

    mhshow:  message 4 has multiple MIME-Version: fields

i see nothing (just a quick read) in RFC 2045 regarding multiple
MIME-Version headers.  certainly if they all match, it's benign, but
i'd think we should be verifying all of them.

my real desire is for mhparse() to be silent if the multiple headers
all say "1.0" -- i can think of no reason for me to care if
"MIME-Version: 1.0" appears multiple times in a message.

the following patch accomplishes this:  all MIME-Version headers are
checked, and all those that are acceptable ("1.0") are ignored
silently.  the patch makes it possible for other programs (mhfixmsg? 
a future "mhverifymsg"?) to easily request the multiple header warning
in the future.

any objections?

paul
=----------------------
 paul fox, [email protected] (arlington, ma, where it's 35.6 degrees)
From 40a26905052f7f00c44ad81c92f2bb38c48e5a4f Mon Sep 17 00:00:00 2001
From: Paul Fox <[email protected]>
Date: Wed, 4 Mar 2015 13:10:38 -0500
Subject: [PATCH] mhparse.c: verify all MIME-Version: headers encountered

in addition to verifying, silently ignore duplicate version headers.
---
 uip/mhparse.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/uip/mhparse.c b/uip/mhparse.c
index dd4c5e9..7c8f07d 100644
--- a/uip/mhparse.c
+++ b/uip/mhparse.c
@@ -41,6 +41,7 @@ int suppress_bogus_mp_content_warning;
 int bogus_mp_content;
 int suppress_extraneous_trailing_semicolon_warning;
 int extraneous_trailing_semicolon;
+int suppress_multiple_mime_version_warning = 1;
 
 /* list of preferred type/subtype pairs, for -prefer */
 char *preferred_types[NPREFS],
@@ -365,16 +366,12 @@ get_content (FILE *in, char *file, int toplevel)
 	if (!strcasecmp (hp->name, VRSN_FIELD)) {
 	    int ucmp;
 	    char c, *cp, *dp;
+	    char *vrsn;
 
-	    if (ct->c_vrsn) {
-		advise (NULL, "message %s has multiple %s: fields",
-			ct->c_file, VRSN_FIELD);
-		goto next_header;
-	    }
-	    ct->c_vrsn = add (hp->value, NULL);
+	    vrsn = add (hp->value, NULL);
 
 	    /* Now, cleanup this field */
-	    cp = ct->c_vrsn;
+	    cp = vrsn;
 
 	    while (isspace ((unsigned char) *cp))
 		cp++;
@@ -401,6 +398,14 @@ get_content (FILE *in, char *file, int toplevel)
 		admonish (NULL, "message %s has unknown value for %s: field (%s)",
 		ct->c_file, VRSN_FIELD, cp);
 	    }
+	    if (!ct->c_vrsn) {
+		ct->c_vrsn = vrsn;
+	    } else {
+		if (! suppress_multiple_mime_version_warning)
+		    advise (NULL, "message %s has multiple %s: fields",
+			    ct->c_file, VRSN_FIELD);
+		free(vrsn);
+	    }
 	}
 	else if (!strcasecmp (hp->name, TYPE_FIELD)) {
 	/* Get Content-Type field */
-- 
1.9.1

_______________________________________________
Nmh-workers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/nmh-workers

Reply via email to