]> diplodocus.org Git - nmh/blobdiff - test/mhfixmsg/test-mhfixmsg
scan(1) now checks for full output device [Bug #50925].
[nmh] / test / mhfixmsg / test-mhfixmsg
index 7fc95d3f1460062acdd15676b5f1ceacfbba467e..138c505123996551aed61b898dddeeca992abe1a 100755 (executable)
@@ -53,6 +53,8 @@ Usage: mhfixmsg [+folder] [msgs] [switches]
   -decodetext 8bit|7bit|binary
   -nodecodetext
   -decodetypes
+  -decodeheaderfieldbodies utf-8
+  -nodecodeheaderfieldbodies
   -[no]crlflinebreaks
   -[no]textcharset
   -[no]reformat
@@ -71,7 +73,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 +181,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 +190,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 +199,13 @@ 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
+start_test "-file with directory"
+run_test 'mhfixmsg -file /tmp' 'mhfixmsg: /tmp is a directory
+mhfixmsg: unable to parse message from file /tmp'
 
 
 # check -reformat (enabled by default):  addition of text/plain part
@@ -357,8 +366,8 @@ else
 fi
 
 
-# check -nodecode
-start_test "-nodecode"
+# check -nodecodetext
+start_test "-nodecodetext"
 prepare_space >"$expected" <<EOF
 MIME-Version: 1.0
 From: sender@example.com
@@ -422,7 +431,7 @@ if [ $can_reformat_texthtml -eq 1 ]; then
   printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$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"
@@ -1369,7 +1378,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
 
 
@@ -1677,7 +1686,7 @@ check "$expected" "$actual"
 start_test "input is passed through to output when there's a parse error"
 cat >"$expected.err" <<EOF
 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
-          (parameter charset)
+    (parameter charset)
 mhfixmsg: unable to parse message 31
 EOF
 
@@ -1720,7 +1729,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
@@ -1783,13 +1792,75 @@ run_prog mhfixmsg -file - -outfile - <`mhpath last` >"$actual" 2>/dev/null
 check "$expected" "$actual"
 
 
+start_test "-nodecodeheaderfieldbodies"
+cat >"`mhpath new`" <<EOF
+To: recipient@example.com
+From: sender@example.com
+Date: Wed, 28 Sep 2016 11:24:28 -0400
+Subject: =?utf-8?B?dGhpcyBTdWJqZWN0IHdhcyBVVEYtOCBlbmNvZGVk?=
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
+Content-Transfer-Encoding: 8bit
+
+--001a114dd3e8fe9c56053d92f414
+Content-Type: text/plain; charset=UTF-8
+
+This is a test.
+
+--001a114dd3e8fe9c56053d92f414
+Content-Type: text/plain; charset=UTF-8; name="test.txt"
+Content-Disposition: attachment; filename="test.txt"
+Content-Transfer-Encoding: 8bit
+
+This is the first text/plain part, in a subpart.  The file name
+is test.txt.
+
+--001a114dd3e8fe9c56053d92f414--
+EOF
+run_prog mhfixmsg -file - -outfile - -decodeheaderfieldbodies utf-8 \
+     -nodecodeheaderfieldbodies <`mhpath last` >"$actual" 2>/dev/null
+check `mhpath last` "$actual" 'keep first'
+
+
+start_test "test decoding of UTF-8 header value"
+cat >"$expected" <<EOF
+To: recipient@example.com
+From: sender@example.com
+Date: Wed, 28 Sep 2016 11:24:28 -0400
+Subject: this Subject was UTF-8 encoded
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
+Content-Transfer-Encoding: 8bit
+
+--001a114dd3e8fe9c56053d92f414
+Content-Type: text/plain; charset=UTF-8
+
+This is a test.
+
+--001a114dd3e8fe9c56053d92f414
+Content-Type: text/plain; charset=UTF-8; name="test.txt"
+Content-Disposition: attachment; filename="test.txt"
+Content-Transfer-Encoding: 8bit
+
+This is the first text/plain part, in a subpart.  The file name
+is test.txt.
+
+--001a114dd3e8fe9c56053d92f414--
+EOF
+
+run_prog mhfixmsg -file - -outfile - -decodeheaderfieldbodies utf-8 \
+     <`mhpath last` >"$actual" 2>/dev/null
+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" <<EOF
 EOF
 
 check "$expected" "$actual"
 
+
 finish_test
 exit $failed