From: David Levine Date: Sat, 27 Apr 2013 18:26:18 +0000 (-0500) Subject: Allow mhfixmsg -reformat to succeed even when decode of binary X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/43242c623638e8b4fc23b46d61dea80765c7a332?hp=52138122dce95e4b17dd5f7947be8b3859dcb7c6 Allow mhfixmsg -reformat to succeed even when decode of binary text fails. This is a refinement of commit ebf35185aa9256b0cd09234f39bd14db9e90e81c. --- diff --git a/test/mhfixmsg/test-mhfixmsg b/test/mhfixmsg/test-mhfixmsg index 5ac77ca5..10ac24ec 100755 --- a/test/mhfixmsg/test-mhfixmsg +++ b/test/mhfixmsg/test-mhfixmsg @@ -409,8 +409,7 @@ This is a text/plain part. ------- =_aaaaaaaaaa0-- EOF -msgfile=`mhpath new` -cat >$msgfile <`mhpath new` <$msgfile <`mhpath new` <$msgfile <`mhpath new` <"$expected" <<'EOF' +MIME-Version: 1.0 +Date: Thu, 11 Apr 2013 02:47:08 -0700 +To: +From: +Subject: body requires binary encoding +Content-Type: multipart/alternative; boundary="----=_nmh-multipart" + +------=_nmh-multipart +Content-Type: text/plain; charset="ISO-8859-1" +Content-Transfer-Encoding: 8bit + +Mile $0.00 +Time $78.71 +State Tax $5.90 +Vehicle License Fee $1.84 +State Txn Tax $6.00 + +------=_nmh-multipart +Content-Type: text/html; charset="ISO-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +------=_nmh-multipart-- +EOF + +cat >`mhpath new` <<'EOF' +MIME-Version: 1.0 +Content-Type: text/html; charset="ISO-8859-1" +Content-Transfer-Encoding: quoted-printable +Date: Thu, 11 Apr 2013 02:47:08 -0700 +To: +From: +Subject: body requires binary encoding + + +
Mile $0.00
Time $78.71
State Tax $5.90
Vehicle License Fee $1.84
State Txn Tax $6.00
+  + + + +EOF + +#### lynx inserts multiple blank lines, so use uniq to squeeze them. +mhfixmsg last -outfile - | uniq >"$actual" +check "$expected" "$actual" 'ignore space' + + # check -textcodeset # Also checks preservation of attributes after one (charset) that is # modified. @@ -607,8 +693,7 @@ EOF #### Generated the encoded text below with: #### $ printf '\xbd\xb2=\xbc\n' | base64 -msgfile=`mhpath new` -cat >$msgfile <`mhpath new` <>"$MH" -cp "${MH_TEST_DIR}/Mail/inbox/14" "${MH_TEST_DIR}/Mail/inbox/14.original" +cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original" -run_test 'mhfixmsg 14' '' -check "${MH_TEST_DIR}/Mail/inbox/14.backup" \ - "${MH_TEST_DIR}/Mail/inbox/14.original" +run_test 'mhfixmsg 15' '' +check "${MH_TEST_DIR}/Mail/inbox/15.backup" \ + "${MH_TEST_DIR}/Mail/inbox/15.original" # check -normmproc -cp "${MH_TEST_DIR}/Mail/inbox/18" "${MH_TEST_DIR}/Mail/inbox/19" +cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20" -run_test 'mhfixmsg 18 -normmproc' -check "${MH_TEST_DIR}/Mail/inbox/19" \ - "${MH_TEST_DIR}/Mail/inbox/,18" 'keep first' +run_test 'mhfixmsg 19 -normmproc' +check "${MH_TEST_DIR}/Mail/inbox/20" \ + "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first' # check -rmmproc -run_test 'mhfixmsg 19 -rmmproc true' -if test -f '${MH_TEST_DIR}/Mail/inbox/19.backup'; then +run_test 'mhfixmsg 20 -rmmproc true' +if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then echo check of mhfixmsg -rmmproc FAILED, should not have created backup file failed=`expr ${failed:-0} + 1` fi diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 2d2fde13..8c5268ef 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -610,7 +610,7 @@ get_multipart_boundary (CT ct, char **part_boundary) { } } } else { - status = NOTOK; + status = NOTOK; } if (status == OK) { @@ -1452,6 +1452,8 @@ decode_text_parts (CT ct, int encoding, int *message_mods) { if (decode_part (ct) == OK && ct->c_cefile.ce_file) { if ((ct_encoding = content_encoding (ct)) == CE_BINARY && encoding != CE_BINARY) { + /* The decoding isn't acceptable so discard it. + Leave status as OK to allow other transformations. */ if (verbosw) { report (ct->c_partno, ct->c_file, "will not decode%s because it is binary", @@ -1462,9 +1464,10 @@ decode_text_parts (CT ct, int encoding, int *message_mods) { unlink (ct->c_cefile.ce_file); free (ct->c_cefile.ce_file); ct->c_cefile.ce_file = NULL; - status = NOTOK; - } else if (ct->c_encoding == CE_QUOTED && + } else if (ct->c_encoding == CE_QUOTED && ct_encoding == CE_8BIT && encoding == CE_7BIT) { + /* The decoding isn't acceptable so discard it. + Leave status as OK to allow other transformations. */ if (verbosw) { report (ct->c_partno, ct->c_file, "will not decode%s because it is 8bit", @@ -1475,7 +1478,6 @@ decode_text_parts (CT ct, int encoding, int *message_mods) { unlink (ct->c_cefile.ce_file); free (ct->c_cefile.ce_file); ct->c_cefile.ce_file = NULL; - status = NOTOK; } else { int enc; if (ct_encoding == CE_BINARY)
Mile $0.00
Time$78.71
<= +font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2">State Tax $5.90
Vehicle License Fee $1.84
State Txn Tax $6.00