X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/bf08a48f1114384817364f40b1e8393466a48355..da4e8725cdfeb62527f9b900f3a21afc88e89e3a:/test/mhfixmsg/test-mhfixmsg diff --git a/test/mhfixmsg/test-mhfixmsg b/test/mhfixmsg/test-mhfixmsg index f741d9c6..66e45a32 100755 --- a/test/mhfixmsg/test-mhfixmsg +++ b/test/mhfixmsg/test-mhfixmsg @@ -53,12 +53,15 @@ Usage: mhfixmsg [+folder] [msgs] [switches] -decodetext 8bit|7bit|binary -nodecodetext -decodetypes + -decodeheaderfieldbodies utf-8 + -nodecodeheaderfieldbodies -[no]crlflinebreaks -[no]textcharset -[no]reformat -[no]replacetextplain -[no]fixboundary -[no]fixcte + -[no]checkbase64 -fixtype mimetype -file file -outfile file @@ -71,7 +74,7 @@ Usage: mhfixmsg [+folder] [msgs] [switches] EOF #### Skip nmh intro text. -run_prog mhfixmsg -help | sed '/^$/,$d' >"$actual" 2>&1 +run_prog mhfixmsg -help 2>&1 | sed '/^$/,$d' >"$actual" check "$expected" "$actual" @@ -179,6 +182,7 @@ run_test 'mhfixmsg last -outfile '"$actual"' -verbose' \ QUOTED-PRINTABLE with 8 bit" check "$expected" "$actual" 'keep first' +sbackup="`mhparam sbackup`" # check with no options: checks backup start_test "with no options: checks backup" @@ -187,7 +191,7 @@ folder last >/dev/null run_test 'mhfixmsg' '' check "$expected" "$MH_TEST_DIR"/Mail/inbox/11 'keep first' cp "$MH_TEST_DIR"/Mail/inbox/11.original "$MH_TEST_DIR"/Mail/inbox/11 -check "$MH_TEST_DIR"/Mail/inbox/,11 "$MH_TEST_DIR"/Mail/inbox/11.original +check "$MH_TEST_DIR/Mail/inbox/${sbackup}11" "$MH_TEST_DIR"/Mail/inbox/11.original # check backup with -file @@ -196,7 +200,7 @@ cp "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/11.original folder last >/dev/null run_test 'mhfixmsg -file '"$MH_TEST_DIR"/Mail/inbox/11 '' check "$MH_TEST_DIR"/Mail/inbox/11 "$expected" 'keep first' -check "$MH_TEST_DIR"/Mail/inbox/,11 "$MH_TEST_DIR"/Mail/inbox/11.original +check "$MH_TEST_DIR/Mail/inbox/${sbackup}11" "$MH_TEST_DIR"/Mail/inbox/11.original # check -file with directory @@ -363,8 +367,8 @@ else fi -# check -nodecode -start_test "-nodecode" +# check -nodecodetext +start_test "-nodecodetext" prepare_space >"$expected" <"$expected.err" #### lynx inserts multiple blank lines, so squeeze them. - run_prog mhfixmsg last -nodecode -outfile - -verbose 2>"$actual.err" | \ + run_prog mhfixmsg last -nodecodetext -outfile - -verbose 2>"$actual.err" | \ squeeze_lines >"$actual" check "$expected" "$actual" 'ignore space' check "$expected.err" "$actual.err" @@ -1375,7 +1379,7 @@ EOF run_test 'mhfixmsg 21 -normmproc' check "${MH_TEST_DIR}/Mail/inbox/22" \ - "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first' + "${MH_TEST_DIR}/Mail/inbox/${sbackup}21" 'keep first' fi @@ -1726,7 +1730,7 @@ check "`mhpath last`" "$actual" 'keep first' start_test "pass through message with relative folder path with parse error" #### Factor out leading portion of current folder path and make it relative. -pwd=`pwd` +pwd=`pwd -P` set +e run_prog mhfixmsg +./`mhpath | sed "s%^$pwd/%%"` last -out - >"$actual" 2>/dev/null set -e @@ -1789,13 +1793,370 @@ run_prog mhfixmsg -file - -outfile - <`mhpath last` >"$actual" 2>/dev/null check "$expected" "$actual" +start_test "-nodecodeheaderfieldbodies" +cat >"`mhpath new`" <"$actual" 2>/dev/null +check `mhpath last` "$actual" 'keep first' + + +start_test "test decoding of UTF-8 header value" +cat >"$expected" <"$actual" 2>/dev/null +check "$expected" "$actual" + + +start_test "-checkbase64 with base64 code that ends with == plus footer" +cat >"`mhpath new`" < +Subject: base64 code that ends with == +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBzb21lIHRleHQuCg== + +-- +Wait, this shouldn't be here. +EOF + +cat >"$expected" < +Subject: base64 code that ends with == +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----=_nmh-multipart" + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +This is some text. + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +-- +Wait, this shouldn't be here. + +------=_nmh-multipart-- +EOF +run_prog mhfixmsg last -outfile "$actual" +check "$expected" "$actual" + + +start_test "-checkbase64 with -nodecodetext" +cat >"`mhpath new`" < +Subject: base64 code that ends with == +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBzb21lIHRleHQuCg== + +-- +Wait, this shouldn't be here. +EOF + +cat >"$expected" < +Subject: base64 code that ends with == +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----=_nmh-multipart" + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBzb21lIHRleHQuCg== + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +-- +Wait, this shouldn't be here. + +------=_nmh-multipart-- +EOF +run_prog mhfixmsg -nodecodetext last -outfile "$actual" +check "$expected" "$actual" + + +start_test "-checkbase64 with base64 code that ends with = plus footer" +cat >"`mhpath new`" < +Subject: base64 code that ends with = +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBwbGFpbiB0ZXh0Lgo= + +-- +Wait, this shouldn't be here. +EOF + +cat >"$expected" < +Subject: base64 code that ends with = +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----=_nmh-multipart" + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +This is plain text. + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +-- +Wait, this shouldn't be here. + +------=_nmh-multipart-- +EOF +run_prog mhfixmsg last -outfile "$actual" +check "$expected" "$actual" + + +start_test "-checkbase64 with base64 code that ends without = plus footer" +cat >"`mhpath new`" < +Subject: base64 code that ends without = +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBzb21lIHRleHQK + +-- +Wait, this shouldn't be here. +EOF + +cat >"$expected" < +Subject: base64 code that ends without = +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----=_nmh-multipart" + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +This is some text + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +-- +Wait, this shouldn't be here. + +------=_nmh-multipart-- +EOF +run_prog mhfixmsg last -outfile "$actual" +check "$expected" "$actual" + + +start_test "-checkbase64 with base64 code that contains single invalid character" +cat >"`mhpath new`" < +Subject: base64 code that ends without = +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBzb21lIHRleHQK + +-X- +Wait, this shouldn't be here. +EOF + +cat >"$expected" < +Subject: base64 code that ends without = +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBzb21lIHRleHQK + +-X- +Wait, this shouldn't be here. +EOF + +cat >"$expected_err" <"$actual_err" || true +check "$expected" "$actual" +check "$expected_err" "$actual_err" + + +start_test "-checkbase64 with base64 code in MIME part" +cat >"`mhpath new`" < +Subject: MIME part with base64 encoded text and unencoded footer +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----=_nmh-multipart" + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBzb21lIHRleHQK + +-- +Wait, this shouldn't be here. + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +This is a second text/plain part. + +------=_nmh-multipart-- +EOF + +cat >"$expected" < +Subject: MIME part with base64 encoded text and unencoded footer +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----=_nmh-multipart" + +------=_nmh-multipart +Content-Type: multipart/mixed; boundary="----=_nmh-multipart1" + +------=_nmh-multipart1 +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +This is some text + +------=_nmh-multipart1 +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +-- +Wait, this shouldn't be here. + +------=_nmh-multipart1-- + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +This is a second text/plain part. + +------=_nmh-multipart-- +EOF +run_prog mhfixmsg last -outfile "$actual" +check "$expected" "$actual" + + +start_test "-checkbase64 with 8-bit encoded base64 code" +cat >"`mhpath new`" < +Subject: 8-bit encoded base64 code +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: base64 + +U2VlIFJGQyAyMDQ1IMKnNi44Lg== + +-- +Wait, this shouldn't be here. +EOF +cat >"$expected" < +Subject: 8-bit encoded base64 code +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----=_nmh-multipart" +Content-Transfer-Encoding: 8bit + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 8bit + +See RFC 2045 §6.8. + +------=_nmh-multipart +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +-- +Wait, this shouldn't be here. + +------=_nmh-multipart-- +EOF + +run_prog mhfixmsg last -outfile "$actual" +check "$expected" "$actual" + + # make sure there are no tmp files left over -find "$MH_TEST_DIR/Mail" \( -name 'mhfix*' -o -name ',mhfix*' \) -print \ +find "$MH_TEST_DIR/Mail" -name '*mhfix*' -print \ >"$actual" cat >"$expected" <