X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/07a260ff4749449f6618358c2d756ae3f5168619..cdec1be974fb9a041d75d4e363463e58766309b3:/uip/mhbuildsbr.c diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 3429c1ef..68c555d3 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -173,6 +173,7 @@ build_mime (char *infile, int autobuild, int dist, int directives, strcasecmp (name, ENCODING_FIELD) == 0) { if (autobuild) { fclose(in); + free (ct); return NULL; } else { adios (NULL, "draft shouldn't contain %s: field", name); @@ -398,7 +399,6 @@ finish_field: if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL) adios (NULL, "out of memory"); *pp = part; - pp = &part->mp_next; part->mp_part = p; } @@ -780,7 +780,6 @@ use_forw: adios (NULL, "out of memory"); init_decoded_content(ct, infilename); *ctp = ct; - ci = &ct->c_ctinfo; if (get_ctinfo (buffer, ct, 0) == NOTOK) done (1); ct->c_type = CT_MESSAGE; @@ -827,14 +826,10 @@ use_forw: * No [file] argument, so check profile for * method to compose content. */ - snprintf (buffer, sizeof(buffer), "%s-compose-%s/%s", - invo_name, ci->ci_type, ci->ci_subtype); - if ((cp = context_find (buffer)) == NULL || *cp == '\0') { - snprintf (buffer, sizeof(buffer), "%s-compose-%s", invo_name, ci->ci_type); - if ((cp = context_find (buffer)) == NULL || *cp == '\0') { - content_error (NULL, ct, "don't know how to compose content"); - done (1); - } + cp = context_find_by_type ("compose", ci->ci_type, ci->ci_subtype); + if (cp == NULL) { + content_error (NULL, ct, "don't know how to compose content"); + done (1); } ci->ci_magic = add (cp, NULL); return OK; @@ -1480,9 +1475,16 @@ scan_content (CT ct, size_t maxunencoded) t = (struct text *) ct->c_ctparams; if (t->tx_charset == CHARSET_UNSPECIFIED) { CI ci = &ct->c_ctinfo; + char *eightbitcharset = write_charset_8bit(); + + if (contains8bit && strcasecmp(eightbitcharset, "US-ASCII") == 0) { + adios(NULL, "Text content contains 8 bit characters, but " + "character set is US-ASCII"); + } add_param(&ci->ci_first_pm, &ci->ci_last_pm, "charset", - contains8bit ? write_charset_8bit() : "us-ascii", 0); + contains8bit ? eightbitcharset : "us-ascii", 0); + t->tx_charset = CHARSET_SPECIFIED; } } @@ -1493,24 +1495,30 @@ scan_content (CT ct, size_t maxunencoded) if (ct->c_reqencoding != CE_UNKNOWN) ct->c_encoding = ct->c_reqencoding; - else + else { + int wants_q_p = (containsnul || linelen || linespace || checksw); + switch (ct->c_type) { case CT_TEXT: - if (contains8bit && !containsnul && !linelen && !linespace && !checksw) - ct->c_encoding = CE_8BIT; - else if (contains8bit || containsnul || linelen || linespace || checksw) - ct->c_encoding = CE_QUOTED; - else - ct->c_encoding = CE_7BIT; + if (wants_q_p) + ct->c_encoding = CE_QUOTED; + else if (contains8bit) + ct->c_encoding = CE_8BIT; + else + ct->c_encoding = CE_7BIT; + break; case CT_APPLICATION: /* For application type, use base64, except when postscript */ - if (containsnul || contains8bit || linelen || linespace || checksw) - ct->c_encoding = (ct->c_subtype == APPLICATION_POSTSCRIPT) - ? CE_QUOTED : CE_BASE64; - else + if (wants_q_p || contains8bit) { + if (ct->c_subtype == APPLICATION_POSTSCRIPT) + ct->c_encoding = CE_QUOTED; /* historical */ + else + ct->c_encoding = CE_BASE64; + } else { ct->c_encoding = CE_7BIT; + } break; case CT_MESSAGE: @@ -1524,6 +1532,7 @@ scan_content (CT ct, size_t maxunencoded) ct->c_encoding = CE_BASE64; break; } + } return (boundaryclash ? NOTOK : OK); } @@ -1856,8 +1865,7 @@ setup_attach_content(CT ct, char *filename) char *type, *simplename = r1bindex(filename, '/'); struct str2init *s2i; PM pm; - char buffer[BUFSIZ], *cp; - int no_subtype = 0; + char *cp; if (! (type = mime_type(filename))) { adios(NULL, "Unable to determine MIME type of \"%s\"", filename); @@ -1937,24 +1945,16 @@ setup_attach_content(CT ct, char *filename) * 'attachment'. */ - snprintf (buffer, sizeof(buffer), "%s-disposition-%s/%s", - invo_name, ct->c_ctinfo.ci_type, ct->c_ctinfo.ci_subtype); - cp = context_find (buffer); - if (cp == NULL || *cp == '\0') { - no_subtype = 1; - snprintf (buffer, sizeof(buffer), "%s-disposition-%s", invo_name, - ct->c_ctinfo.ci_type); - cp = context_find (buffer); - } - if (cp != NULL && *cp != '\0') { - if (strcasecmp (cp, "attachment") && - strcasecmp (cp, "inline")) { + cp = context_find_by_type ("disposition", ct->c_ctinfo.ci_type, + ct->c_ctinfo.ci_subtype); + if (cp != NULL) { + if (strcasecmp (cp, "attachment") && strcasecmp (cp, "inline")) { admonish (NULL, "configuration problem: %s-disposition-%s%s%s " "specifies '%s' but only 'attachment' and 'inline' are " "allowed", invo_name, ct->c_ctinfo.ci_type, - no_subtype ? "" : "/", - no_subtype ? "" : ct->c_ctinfo.ci_subtype, + ct->c_ctinfo.ci_subtype ? "/" : "", + ct->c_ctinfo.ci_subtype ? ct->c_ctinfo.ci_subtype : "", cp); } }