]> diplodocus.org Git - nmh/commitdiff
mhparse.c: verify all MIME-Version: headers encountered
authorPaul Fox <pgf@foxharp.boston.ma.us>
Wed, 4 Mar 2015 18:10:38 +0000 (13:10 -0500)
committerPaul Fox <pgf@foxharp.boston.ma.us>
Thu, 5 Mar 2015 01:26:10 +0000 (20:26 -0500)
in addition to verifying, silently ignore duplicate version headers.

uip/mhparse.c

index dd4c5e9a26ad93ae56a56af65e38afd171050014..7c8f07dc73ca4090038c4d77f329f99317809188 100644 (file)
@@ -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 */