]> diplodocus.org Git - nmh/blobdiff - uip/mhparse.c
Added -convertargs switch to repl(1), to pass arguments to programs
[nmh] / uip / mhparse.c
index 69bb542e7c56cca2088ef18bc3addf9eeb6db77a..96af58e9e04327364103a7a6ff12321aa8821cbf 100644 (file)
@@ -34,10 +34,14 @@ int checksw = 0;    /* check Content-MD5 field */
  * 1) Instruct parser not to detect invalid Content-Transfer-Encoding
  *    in a multipart.
  * 2) Suppress the warning about bogus multipart content, and report it.
+ * 3) Suppress the warning about extraneous trailing ';' in header parameter
+ *    lists, and report it.
  */
 int skip_mp_cte_check;
 int suppress_bogus_mp_content_warning;
 int bogus_mp_content;
+int suppress_extraneous_trailing_semicolon_warning;
+int extraneous_trailing_semicolon;
 
 /*
  * Structures for TEXT messages
@@ -59,6 +63,7 @@ struct k2v SubMultiPart[] = {
     { "alternative", MULTI_ALTERNATE },
     { "digest",      MULTI_DIGEST },
     { "parallel",    MULTI_PARALLEL },
+    { "related",     MULTI_RELATED },
     { NULL,          MULTI_UNKNOWN }    /* this one must be last! */
 };
 
@@ -1179,7 +1184,6 @@ next_part:
            if (!(p = get_content (fp, ct->c_file,
                        ct->c_subtype == MULTI_DIGEST ? -1 : 0))) {
                free(bufp);
-               fclose (ct->c_fp);
                ct->c_fp = NULL;
                return NOTOK;
            }
@@ -2127,6 +2131,7 @@ ready_to_go:
       fclose (ct->c_fp);
       ct->c_fp = NULL;
     }
+    free (bufp);
     return fileno (ce->ce_fp);
 
 clean_up:
@@ -2135,6 +2140,7 @@ clean_up:
       fclose (ct->c_fp);
       ct->c_fp = NULL;
     }
+    free (bufp);
     return NOTOK;
 }
 
@@ -3148,6 +3154,8 @@ ct_subtype_str (int type, int subtype) {
             return "digest";
         case MULTI_PARALLEL:
             return "parallel";
+        case MULTI_RELATED:
+            return "related";
         default:
             return "unknown_multipart_subtype";
         }
@@ -3272,10 +3280,13 @@ parse_header_attrs (const char *filename, const char *fieldname,
         }
 
        if (*cp == 0) {
-           advise (NULL,
-                   "extraneous trailing ';' in message %s's %s: "
-                    "parameter list",
-                   filename, fieldname);
+           if (! suppress_extraneous_trailing_semicolon_warning) {
+               advise (NULL,
+                       "extraneous trailing ';' in message %s's %s: "
+                       "parameter list",
+                       filename, fieldname);
+           }
+           extraneous_trailing_semicolon = 1;
            return DONE;
        }
 
@@ -3550,6 +3561,7 @@ bad_quote:
                                "%s's %s: field\n%*s(parameter %s)", sp->index,
                                filename, fieldname, strlen(invo_name) + 2, "",
                                nameptr);
+                       free (nameptr);
                        return NOTOK;
                    }
                    if (sp2->index < sp->index &&
@@ -3565,6 +3577,7 @@ bad_quote:
                           "param in message %s's %s: field\n%*s(parameter %s)",
                           filename, fieldname, strlen(invo_name) + 2, "",
                           nameptr);
+                   free (nameptr);
                    return NOTOK;
                }
            }
@@ -3640,21 +3653,16 @@ bad_quote:
 }
 
 /*
- * Return the charset for a particular content type.  Return pointer is
- * only valid until the next call to content_charset().
+ * Return the charset for a particular content type.
  */
 
 char *
 content_charset (CT ct) {
-    static char *ret_charset = NULL;
-
-    if (ret_charset != NULL) {
-       free(ret_charset);
-    }
+    char *ret_charset = NULL;
 
     ret_charset = get_param(ct->c_ctinfo.ci_first_pm, "charset", '?', 0);
 
-    return ret_charset ? ret_charset : "US-ASCII";
+    return ret_charset ? ret_charset : getcpy ("US-ASCII");
 }