]> diplodocus.org Git - nmh/blobdiff - uip/mhbuildsbr.c
Fixed inc(1) and %(me) to not obey Local-Mailbox profile component.
[nmh] / uip / mhbuildsbr.c
index cee0ee568722bf2343394f1071f52670b93ed425..b96e63ac03e86e812d7d9aa9bae7fc031eb4dede 100644 (file)
@@ -42,7 +42,6 @@
 #include "h/mhparse.h"
 #include "h/done.h"
 #include "h/utils.h"
-#include "h/mhcachesbr.h"
 #include "mhmisc.h"
 #include "sbr/m_mktemp.h"
 #include "sbr/message_id.h"
@@ -191,9 +190,20 @@ build_mime (char *infile, int autobuild, int dist, int directives,
        case FLDPLUS:
            compnum++;
 
-           /* abort if draft has Mime-Version or C-T-E header field */
-           if (strcasecmp (name, VRSN_FIELD) == 0 ||
-               strcasecmp (name, ENCODING_FIELD) == 0) {
+           /*
+            * If we are running with autobuild set, then silently
+            * exit if we find a MIME-Version header.  For any other MIME
+            * header, return an error.
+            *
+            * RFC 2045, Section 9 says that any valid MIME header should
+            * start with "Content-", so we will match on that rather than
+            * enumerate all current MIME headers.
+            *
+            * Because the headers could be in any order, just check for
+            * MIME-Version here; check for Content-* later.
+            */
+
+           if (strcasecmp (name, VRSN_FIELD) == 0) {
                if (autobuild) {
                    fclose(in);
                    free (ct);
@@ -202,15 +212,6 @@ build_mime (char *infile, int autobuild, int dist, int directives,
                 die("draft shouldn't contain %s: field", name);
            }
 
-           /* ignore any Content-Type fields in the header */
-           if (!strcasecmp (name, TYPE_FIELD)) {
-               while (state == FLDPLUS) {
-                   bufsz = sizeof buf;
-                   state = m_getfld2(&gstate, name, buf, &bufsz);
-               }
-               goto finish_field;
-           }
-
            /* get copies of the buffers */
            np = mh_xstrdup(name);
            vp = mh_xstrdup(buf);
@@ -366,6 +367,16 @@ finish_field:
     }
     m_getfld_state_destroy (&gstate);
 
+    /*
+     * If we see any Content-* headers at this point, it is an error.
+     */
+
+    for (hp = ct->c_first_hf; hp != NULL; hp = hp->next) {
+       if (uprf (hp->name, "Content-")) {
+           die ("draft shouldn't contain %s: field", hp->name);
+       }
+    }
+
     if (header_encoding != CE_8BIT) {
         /*
          * Iterate through the list of headers and call the function to MIME-ify