X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/ef0f97190a3a81a91c7564388c2782b0ff40d5fe..baecaa2380db6164c1992fdffccca8ea9a61d5ba:/uip/mhbuildsbr.c diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 9cc56351..b9989934 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -2160,7 +2159,7 @@ expand_pseudoheaders (CT ct, struct multipart *m, const char *infile, part->mp_part->c_ctinfo.ci_subtype, NULL); if (part->mp_part->c_type == CT_MULTIPART) { - expand_pseudoheaders (part->mp_part, mp, infile, + expand_pseudoheaders (part->mp_part, m, infile, convert_head); } else { const convert_list *c; @@ -2221,6 +2220,7 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m, struct str2init *s2i; CT reply_ct; struct part *part; + int status; type_p = getcpy (type); if ((subtype_p = strchr (type_p, '/'))) { @@ -2247,7 +2247,9 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m, /* Convert here . . . */ ct->c_storeproc = getcpy (convert_command); ct->c_umask = ~m_gmprot (); - if (show_content_aux (ct, 0, convert_command, NULL, NULL) == NOTOK) { + + if ((status = show_content_aux (ct, 0, convert_command, NULL, NULL)) != + OK) { admonish (NULL, "store of %s content failed", type); } free (convert_command); @@ -2283,26 +2285,27 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m, } else { set_charset (reply_ct, -1); charset = get_param (reply_ct->c_ctinfo.ci_first_pm, "charset", '?', 1); - if (reply_ct->c_reqencoding == CE_UNKNOWN && - strcasecmp (charset, "US-ASCII")) { + if (reply_ct->c_reqencoding == CE_UNKNOWN) { /* Assume that 8bit is sufficient (for text). */ - reply_ct->c_reqencoding = CE_8BIT; + reply_ct->c_reqencoding = + strcasecmp (charset, "US-ASCII") ? CE_8BIT : CE_7BIT; } } /* Concatenate text/plain parts. */ if (reply_ct->c_type == CT_TEXT && reply_ct->c_subtype == TEXT_PLAIN) { - - if (m->mp_parts && ! *text_plain_ct) { + if (! *text_plain_ct && m->mp_parts && m->mp_parts->mp_part && + m->mp_parts->mp_part->c_type == CT_TEXT && + m->mp_parts->mp_part->c_subtype == TEXT_PLAIN) { *text_plain_ct = m->mp_parts->mp_part; /* Make sure that the charset is set in the text/plain part. */ set_charset (*text_plain_ct, -1); - if ((*text_plain_ct)->c_reqencoding == CE_UNKNOWN && - strcasecmp (charset, "US-ASCII")) { + if ((*text_plain_ct)->c_reqencoding == CE_UNKNOWN) { /* Assume that 8bit is sufficient (for text). */ - (*text_plain_ct)->c_reqencoding = CE_8BIT; + (*text_plain_ct)->c_reqencoding = + strcasecmp (charset, "US-ASCII") ? CE_8BIT : CE_7BIT; } } @@ -2323,6 +2326,7 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m, if (text_plain_reply != NOTOK && addl_reply != NOTOK) { /* Insert blank line before each addl part. */ + /* It would be nice not to do this for the first one. */ if (write (text_plain_reply, "\n", 1) == 1) { /* Copy the text from the new reply and then free its Content struct. */ @@ -2386,12 +2390,15 @@ extract_headers (CT ct, char *reply_file, FILE **reply_fp) { buffer[statbuf.st_size] = '\0'; /* Look for a header in the convert reply. */ - if ((end_of_header = strstr (buffer, "\r\n\r\n"))) { - end_of_header += 2; - found_header = 1; - } else if ((end_of_header = strstr (buffer, "\n\n"))) { - ++end_of_header; - found_header = 1; + if (strncasecmp (buffer, TYPE_FIELD, strlen (TYPE_FIELD)) == 0 && + buffer[strlen (TYPE_FIELD)] == ':') { + if ((end_of_header = strstr (buffer, "\r\n\r\n"))) { + end_of_header += 2; + found_header = 1; + } else if ((end_of_header = strstr (buffer, "\n\n"))) { + ++end_of_header; + found_header = 1; + } } if (found_header) {