From: David Levine Date: Mon, 3 Oct 2016 21:50:35 +0000 (-0400) Subject: Fix C-T-E of message, as well as multipart, types to be 7bit, 8bit, X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/c0ee509559273a5133ff73026e76c19aca65fa87?ds=inline Fix C-T-E of message, as well as multipart, types to be 7bit, 8bit, or binary. --- diff --git a/man/mhfixmsg.man b/man/mhfixmsg.man index 88c08a79..2c3df7a4 100644 --- a/man/mhfixmsg.man +++ b/man/mhfixmsg.man @@ -1,4 +1,4 @@ -.TH MHFIXMSG %manext1% "October 1, 2016" "%nmhversion%" +.TH MHFIXMSG %manext1% "October 3, 2016" "%nmhversion%" .\" .\" %nmhwarning% .\" @@ -191,9 +191,9 @@ The .B \-fixcte switch enables a transformation to change the Content-Transfer-Encoding from an invalid value to 8bit in message -parts with a Content-Type of multipart, as required by RFC 2045, -§6.4. That condition is indicated by a \*(lqmust be encoded in -7bit, 8bit, or binary\*(rq error message from +parts with a Content-Type of multipart and message, as required by +RFC 2045, §6.4. That condition is indicated by a \*(lqmust be +encoded in 7bit, 8bit, or binary\*(rq error message from .B mhlist and other .B nmh @@ -305,7 +305,7 @@ content type and/or encoding as follows: \-textcharset text/plain parts \-reformat text parts that are not text/plain \-fixboundary outermost multipart part -\-fixcte multipart part +\-fixcte multipart or message part \-fixtype all except multipart and message parts .fi .RE diff --git a/test/mhfixmsg/test-mhfixmsg b/test/mhfixmsg/test-mhfixmsg index e5df1430..ab0ebcb0 100755 --- a/test/mhfixmsg/test-mhfixmsg +++ b/test/mhfixmsg/test-mhfixmsg @@ -1725,13 +1725,10 @@ MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414 --001a114dd3e8fe9c56053d92f414 - Content-Type: text/plain; charset=UTF-8 This is a test. ---001a114dd3e8fe9c4a053d92f412-- - --001a114dd3e8fe9c56053d92f414 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt @@ -1752,13 +1749,10 @@ MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414 --001a114dd3e8fe9c56053d92f414 - Content-Type: text/plain; charset=UTF-8 This is a test. ---001a114dd3e8fe9c4a053d92f412-- - --001a114dd3e8fe9c56053d92f414 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?=" Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?=" diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 2bc65a9d..55db2c0b 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -27,8 +27,8 @@ X("noreplacetextplain", 0, NREPLACETEXTPLAINSW) \ X("fixboundary", 0, FIXBOUNDARYSW) \ X("nofixboundary", 0, NFIXBOUNDARYSW) \ - X("fixcte", 0, FIXCTESW) \ - X("nofixcte", 0, NFIXCTESW) \ + X("fixcte", 0, FIXCOMPOSITECTESW) \ + X("nofixcte", 0, NFIXCOMPOSITECTESW) \ X("fixtype mimetype", 0, FIXTYPESW) \ X("file file", 0, FILESW) \ X("outfile file", 0, OUTFILESW) \ @@ -78,7 +78,7 @@ void freects_done (int) NORETURN; */ typedef struct fix_transformations { int fixboundary; - int fixcte; + int fixcompositecte; svector_t fixtypes; int reformat; int replacetextplain; @@ -97,7 +97,7 @@ static int replace_boundary (CT, char *, char *); static int fix_types (CT, svector_t, int *); static char *replace_substring (char **, const char *, const char *); static char *remove_parameter (char *, const char *); -static int fix_multipart_cte (CT, int *); +static int fix_composite_cte (CT, int *); static int set_ce (CT, int); static int ensure_text_plain (CT *, CT, int *, int); static int find_textplain_sibling (CT, int, int *); @@ -142,7 +142,7 @@ main (int argc, char **argv) { int chgflag = 1; int status = OK; fix_transformations fx; - fx.reformat = fx.fixcte = fx.fixboundary = 1; + fx.reformat = fx.fixcompositecte = fx.fixboundary = 1; fx.fixtypes = NULL; fx.replacetextplain = 0; fx.decodetext = CE_8BIT; @@ -222,11 +222,11 @@ main (int argc, char **argv) { case NFIXBOUNDARYSW: fx.fixboundary = 0; continue; - case FIXCTESW: - fx.fixcte = 1; + case FIXCOMPOSITECTESW: + fx.fixcompositecte = 1; continue; - case NFIXCTESW: - fx.fixcte = 0; + case NFIXCOMPOSITECTESW: + fx.fixcompositecte = 0; continue; case FIXTYPESW: if (! (cp = *argp++) || (*cp == '-' && cp[1])) { @@ -518,8 +518,8 @@ mhfixmsgsbr (CT *ctp, const fix_transformations *fx, char *outfile) { if (status == OK && fx->fixtypes != NULL) { status = fix_types (*ctp, fx->fixtypes, &message_mods); } - if (status == OK && fx->fixcte) { - status = fix_multipart_cte (*ctp, &message_mods); + if (status == OK && fx->fixcompositecte) { + status = fix_composite_cte (*ctp, &message_mods); } if (status == OK && fx->reformat) { status = @@ -1057,16 +1057,15 @@ remove_parameter (char *str, const char *name) { /* - * Fix Content-Transfer-Encoding. + * Fix Content-Transfer-Encoding of composite,, e.g., message or multipart, part. + * According to RFC 2045 Sec. 6.4, it must be 7bit, 8bit, or binary. Set it to + * 8 bit. */ static int -fix_multipart_cte (CT ct, int *message_mods) { +fix_composite_cte (CT ct, int *message_mods) { int status = OK; - if (ct->c_type == CT_MULTIPART) { - struct multipart *m; - struct part *part; - + if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART) { if (ct->c_encoding != CE_7BIT && ct->c_encoding != CE_8BIT && ct->c_encoding != CE_BINARY) { HF hf; @@ -1112,11 +1111,16 @@ fix_multipart_cte (CT ct, int *message_mods) { set_ce (ct, CE_8BIT); } - m = (struct multipart *) ct->c_ctparams; - for (part = m->mp_parts; part; part = part->mp_next) { - if (fix_multipart_cte (part->mp_part, message_mods) != OK) { - status = NOTOK; - break; + if (ct->c_type == CT_MULTIPART) { + struct multipart *m; + struct part *part; + + m = (struct multipart *) ct->c_ctparams; + for (part = m->mp_parts; part; part = part->mp_next) { + if (fix_composite_cte (part->mp_part, message_mods) != OK) { + status = NOTOK; + break; + } } } }