check "$expected" "$actual"
+# check that message is not modified when -fixboundary fails
+cat >`mhpath new` <<EOF
+Date: Fri, 13 May 2011 08:21:12 -0500
+Content-Type: multipart/alternative;
+ boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
+Content-Transfer-Encoding: 8bit
+MIME-Version: 1.0
+From: <sender@example.com>
+To: <recipient@example.com>
+Subject: mhfixmsg bad boundary test
+
+This is a multi-part message in MIME format.
+
+------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
+Content-Type: text/plain
+
+The boundary below doesn't match the header boundary.
+
+------=_
+NextPart_000_1781A1A_01CC1147.81EBA8D4--
+EOF
+
+cp -p `mhpath last` "$expected"
+run_test "mhfixmsg last -outfile $actual" ''
+check "$expected" "$actual"
+
+
# check that text/plain part is not added to text/html in multipart/related
# when it shouldn't be
cat >`mhpath new` <<EOF
# check -normmproc
-cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
+cp "${MH_TEST_DIR}/Mail/inbox/20" "${MH_TEST_DIR}/Mail/inbox/21"
-run_test 'mhfixmsg 19 -normmproc'
-check "${MH_TEST_DIR}/Mail/inbox/20" \
- "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
+run_test 'mhfixmsg 20 -normmproc'
+check "${MH_TEST_DIR}/Mail/inbox/21" \
+ "${MH_TEST_DIR}/Mail/inbox/,20" 'keep first'
# check -rmmproc
-run_test 'mhfixmsg 20 -rmmproc true'
-if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
+run_test 'mhfixmsg 21 -rmmproc true'
+if test -f '${MH_TEST_DIR}/Mail/inbox/21.backup'; then
echo check of mhfixmsg -rmmproc FAILED, should not have created backup file
failed=`expr ${failed:-0} + 1`
fi
check "$expected" "$actual"
+# check that input is passed through to output when there's a parse error
+# (the charset string is missing its closing quote) with -outfile
+cat >"$expected.err" <<EOF
+mhfixmsg: invalid quoted-string in message 30's Content-Type: field
+ (parameter charset)
+mhfixmsg: unable to parse message 30
+EOF
+
+cat >`mhpath new` <<EOF
+To: recipient@example.com
+From: sender@example.com
+Subject: mhfixmsg pass through on parse error
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="iso-8859-1
+Content-Disposition: attachment; filename="test1.txt"
+Content-Transfer-Encoding: quoted-printable
+
+This is the=
+ text/plain part.
+
+------- =_aaaaaaaaaa0--
+EOF
+set +e
+run_prog mhfixmsg last -outfile "$actual" 2>"$actual.err"
+set -e
+#### Expected output is identical to the input message.
+check `mhpath last` "$actual" 'keep first'
+check "$expected.err" "$actual.err"
+
+
+# check that input is passed through to output when there's a parse error
+# (the charset string is missing its closing quote) with -outfile, and
+# input from stdin. Don't check err output, because it contains the name
+# of a tmp file. It's similar to that of the previous check.
+set +e
+run_prog mhfixmsg -file - -outfile - <`mhpath last` >"$actual" 2>/dev/null
+set -e
+#### Expected output is identical to the input message.
+check `mhpath last` "$actual"
+
+
# make sure there are no tmp files left over
find "$MH_TEST_DIR/Mail" \( -name 'mhfix*' -o -name ',mhfix*' \) -print \
>"$actual"