]> diplodocus.org Git - nmh/blobdiff - test/mhfixmsg/test-mhfixmsg
OK, don't run test-version-check if not connected to terminal.
[nmh] / test / mhfixmsg / test-mhfixmsg
index 152b11c7913c1ca4f58175d02c00ee664fe047a2..9e29fa00f20755177602c35ca72c697e690db597 100755 (executable)
@@ -212,13 +212,13 @@ Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
 
 ------=_nmh-multipart
 Content-Type: text/plain; charset="Windows-1252"
 
 ------=_nmh-multipart
 Content-Type: text/plain; charset="Windows-1252"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 Need to go! Need ... to ... go!
 
 ------=_nmh-multipart
 Content-Type: text/html; charset="Windows-1252"
 
 Need to go! Need ... to ... go!
 
 ------=_nmh-multipart
 Content-Type: text/html; charset="Windows-1252"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 <html>
 <head>
 
 <html>
 <head>
@@ -291,7 +291,7 @@ Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
 
 ------=_nmh-multipart-3
 Content-Type: text/plain; charset="Windows-1252"
 
 ------=_nmh-multipart-3
 Content-Type: text/plain; charset="Windows-1252"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 ------=_nmh-multipart
 ------=_nmh-multipart-1
 
 ------=_nmh-multipart
 ------=_nmh-multipart-1
@@ -299,7 +299,7 @@ Content-Transfer-Encoding: 8bit
 
 ------=_nmh-multipart-3
 Content-Type: text/html; charset="Windows-1252"
 
 ------=_nmh-multipart-3
 Content-Type: text/html; charset="Windows-1252"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 <html>
 <head>
 
 <html>
 <head>
@@ -369,7 +369,7 @@ Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
 
 ------=_nmh-multipart
 Content-Type: text/plain; charset="Windows-1252"
 
 ------=_nmh-multipart
 Content-Type: text/plain; charset="Windows-1252"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 Need to go! Need ... to ... go!
 
 
 Need to go! Need ... to ... go!
 
@@ -443,7 +443,7 @@ Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
 Content-Disposition: attachment; filename="test4.txt"
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
 Content-Disposition: attachment; filename="test4.txt"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is a text/plain part.
 
 
 This is a text/plain part.
 
@@ -500,7 +500,7 @@ This is additional content after the last subpart of the multipart.
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test2.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test2.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is the second text/plain part.
 
 
 This is the second text/plain part.
 
@@ -513,7 +513,7 @@ This is the third text/plain part.
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
 Content-Disposition: attachment; filename="test4.txt"
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
 Content-Disposition: attachment; filename="test4.txt"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is the fourth text/plain part.
 
 
 This is the fourth text/plain part.
 
@@ -586,7 +586,7 @@ MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 
 ------- =_aaaaaaaaaa0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/plain; charset=UTF-8; name="nul+square.txt"
+Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
 Content-Transfer-Encoding: base64
 
 vbI9vAAK
 Content-Transfer-Encoding: base64
 
 vbI9vAAK
@@ -611,7 +611,7 @@ Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="iso-8859-1"
 
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="iso-8859-1"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is a text plain part
 
 
 This is a text plain part
 
@@ -697,10 +697,11 @@ From: sender@example.com
 Subject: mhfixmsg successful decode of text/plain with failed binary decode
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 Subject: mhfixmsg successful decode of text/plain with failed binary decode
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+Content-Transfer-Encoding: binary
 
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="iso-8859-1"
 
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="iso-8859-1"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is a text plain part
 
 
 This is a text plain part
 
@@ -725,9 +726,10 @@ From: sender@example.com
 Subject: mhfixmsg binary decode test
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
 Subject: mhfixmsg binary decode test
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
+Content-Transfer-Encoding: binary
 
 ------- =_aaaaaaaaaa0
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/plain; charset=UTF-8; name=\"nul+square.txt\"
+Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
 Content-Transfer-Encoding: binary
 
 " "
 Content-Transfer-Encoding: binary
 
 " "
@@ -750,7 +752,7 @@ Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
 
 ------=_nmh-multipart
 Content-Type: text/plain; charset="ISO-8859-1"
 
 ------=_nmh-multipart
 Content-Type: text/plain; charset="ISO-8859-1"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 Mile                                     $0.00
 Time                                    $78.71
 
 Mile                                     $0.00
 Time                                    $78.71
@@ -821,6 +823,7 @@ From: sender@example.com
 Subject: mhfixmsg textcharset test
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 Subject: mhfixmsg textcharset test
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+Content-Transfer-Encoding: 8bit
 
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="utf-8"; name="square.txt"
 
 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="utf-8"; name="square.txt"
@@ -1198,13 +1201,12 @@ Content-Type: multipart/alternative; boundary="----=_Part_876302"
 
 ------=_Part_876302
 Content-Type: text/plain; charset="UTF-8"
 
 ------=_Part_876302
 Content-Type: text/plain; charset="UTF-8"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 Yes, the text/plain part really was empty.
 
 ------=_Part_876302
 Content-Type: text/html; charset="UTF-8"
 
 Yes, the text/plain part really was empty.
 
 ------=_Part_876302
 Content-Type: text/html; charset="UTF-8"
-Content-Transfer-Encoding: 8bit
 Content-Disposition: inline
 
 <html><head>
 Content-Disposition: inline
 
 <html><head>
@@ -1234,7 +1236,6 @@ Content-Disposition: inline
 
 ------=_Part_876302
 Content-Type: text/html; charset="UTF-8"
 
 ------=_Part_876302
 Content-Type: text/html; charset="UTF-8"
-Content-Transfer-Encoding: 8bit
 Content-Disposition: inline
 
 <html><head>
 Content-Disposition: inline
 
 <html><head>
@@ -1276,7 +1277,6 @@ Content-Disposition: inline
 
 ------=_Part_876302
 Content-Type: text/html; charset="UTF-8"
 
 ------=_Part_876302
 Content-Type: text/html; charset="UTF-8"
-Content-Transfer-Encoding: 8bit
 Content-Disposition: inline
 
 <html><head>
 Content-Disposition: inline
 
 <html><head>
@@ -1428,14 +1428,14 @@ Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
 Content-Disposition: attachment; filename="test2.txt"
 
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
 Content-Disposition: attachment; filename="test2.txt"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 <html>
 <head>
 
 <html>
 <head>
@@ -1489,7 +1489,7 @@ Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is the text/plain part.
 
 
 This is the text/plain part.
 
@@ -1546,14 +1546,14 @@ Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
 Content-Disposition: attachment; filename="invite.ics"
 
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
 Content-Disposition: attachment; filename="invite.ics"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 BEGIN:VCALENDAR\r
 VERSION:2.0\r
 
 BEGIN:VCALENDAR\r
 VERSION:2.0\r
@@ -1614,14 +1614,14 @@ Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
 Content-Disposition: attachment; filename="invite.ics"
 
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
 Content-Disposition: attachment; filename="invite.ics"
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 
 BEGIN:VCALENDAR
 VERSION:2.0
 
 BEGIN:VCALENDAR
 VERSION:2.0
@@ -1715,6 +1715,59 @@ set -e
 check `mhpath last` "$actual"
 
 
 check `mhpath last` "$actual"
 
 
+start_test "fix RFC 2047 encoded header parameters"
+cat >"$expected" <<EOF
+To: recipient@example.com
+From: sender@example.com
+Date: Wed, 28 Sep 2016 11:24:28 -0400
+Subject: invalid header parameter encoding
+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*=UTF-8''test%C3%B8.txt
+Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
+Content-Transfer-Encoding: 8bit
+
+This is the first text/plain part, in a subpart.  The file name
+is testø.txt.
+
+--001a114dd3e8fe9c56053d92f414--
+EOF
+
+cat >`mhpath new` <<EOF
+To: recipient@example.com
+From: sender@example.com
+Date: Wed, 28 Sep 2016 11:24:28 -0400
+Subject: invalid header parameter encoding
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
+
+--001a114dd3e8fe9c56053d92f414
+Content-Type: text/plain; charset=UTF-8
+
+This is a test.
+
+--001a114dd3e8fe9c56053d92f414
+Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
+Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
+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 - <`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 \
   >"$actual"
 # make sure there are no tmp files left over
 find "$MH_TEST_DIR/Mail" \( -name 'mhfix*' -o -name ',mhfix*' \) -print \
   >"$actual"