+ case CT_MESSAGE:
+ if (ct->c_subtype == MESSAGE_EXTERNAL) {
+ struct exbody *e = (struct exbody *) ct->c_ctparams;
+
+ status = fix_types (e->eb_content, fixtypes, message_mods);
+ }
+ break;
+
+ default: {
+ char **typep, *type;
+
+ if (ct->c_ctinfo.ci_type && ct->c_ctinfo.ci_subtype) {
+ for (typep = svector_strs (fixtypes);
+ typep && (type = *typep);
+ ++typep) {
+ char *type_subtype =
+ concat (ct->c_ctinfo.ci_type, "/", ct->c_ctinfo.ci_subtype,
+ NULL);
+
+ if (! strcasecmp (type, type_subtype) &&
+ decode_part (ct) == OK &&
+ ct->c_cefile.ce_file != NULL) {
+ char *ct_type_subtype = mime_type (ct->c_cefile.ce_file);
+ char *cp;
+
+ if ((cp = strchr (ct_type_subtype, ';'))) {
+ /* Truncate to remove any parameter list from
+ mime_type () result. */
+ *cp = '\0';
+ }
+
+ if (strcasecmp (type, ct_type_subtype)) {
+ char *ct_type, *ct_subtype;
+ HF hf;
+
+ /* The Content-Type header does not match the
+ content, so update these struct Content
+ fields to match:
+ * c_type, c_subtype
+ * c_ctinfo.ci_type, c_ctinfo.ci_subtype
+ * c_ctline
+ */
+ /* Extract type and subtype from type/subtype. */
+ ct_type = mh_xstrdup(ct_type_subtype);
+ if ((cp = strchr (ct_type, '/'))) {
+ *cp = '\0';
+ ct_subtype = mh_xstrdup(++cp);
+ } else {
+ advise (NULL, "missing / in MIME type of %s %s",
+ ct->c_file, ct->c_partno);
+ free (ct_type);
+ return NOTOK;
+ }
+
+ ct->c_type = ct_str_type (ct_type);
+ ct->c_subtype = ct_str_subtype (ct->c_type, ct_subtype);
+
+ free (ct->c_ctinfo.ci_type);
+ ct->c_ctinfo.ci_type = ct_type;
+ free (ct->c_ctinfo.ci_subtype);
+ ct->c_ctinfo.ci_subtype = ct_subtype;
+ if (! replace_substring (&ct->c_ctline, type,
+ ct_type_subtype)) {
+ advise (NULL, "did not find %s in %s",
+ type, ct->c_ctline);
+ }
+
+ /* Update Content-Type header field. */
+ for (hf = ct->c_first_hf; hf; hf = hf->next) {
+ if (! strcasecmp (TYPE_FIELD, hf->name)) {
+ if (replace_substring (&hf->value, type,
+ ct_type_subtype)) {
+ ++*message_mods;
+ if (verbosw) {
+ report (NULL, ct->c_partno, ct->c_file,
+ "change Content-Type in header "
+ "from %s to %s",
+ type, ct_type_subtype);
+ }
+ break;
+ } else {
+ advise (NULL, "did not find %s in %s",
+ type, hf->value);
+ }
+ }
+ }
+ }
+ free (ct_type_subtype);
+ }
+ free (type_subtype);
+ }
+ }
+ }}
+
+ return status;
+}
+
+
+/*
+ * Replace a substring, allocating space to hold the new one.
+ */
+char *
+replace_substring (char **str, const char *old, const char *new) {
+ char *cp;