2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"${srcdir}/test/post/test-post-common.sh"
18 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
19 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
20 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
21 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
24 if grep mhfixmsg-format
-text
/html
"${MH_TEST_DIR}/Mail/mhn.defaults" \
26 can_reformat_texthtml
=1
28 echo "$0: skipping -reformat check because
29 mhfixmsg-format-text/html is not available"
30 can_reformat_texthtml
=0
36 # Verified behavior consistent with compiled sendmail.
37 cat >"$expected" <<EOF
38 Usage: mhfixmsg [+folder] [msgs] [switches]
55 mhfixmsg
-help >"$actual" 2>&1
56 check
"$expected" "$actual"
60 # Verified same behavior as compiled mhfixmsg.
61 case `mhfixmsg -version` in
63 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
64 failed
=`expr ${failed:-0} + 1`;;
68 cat >`mhpath new` <<'EOF'
70 Content-Type: text/html; charset="ISO-8859-1"
71 Content-Transfer-Encoding: quoted-printable
72 Date: Thu, 11 Apr 2013 02:47:08 -0700
74 From: <sender@example.com>
75 Subject: body requires binary encoding
78 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
79 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
80 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
81 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
82 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
83 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
84 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
85 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
86 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
87 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
88 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
89 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
90 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
91 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
92 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
93 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
94 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
95 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
96 #333333" size=3D"2">$6.00</font></td></tr>
102 if [ $can_reformat_texthtml -eq 1 ]; then
103 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
104 mhfixmsg last
-outfile - | uniq >"$actual"
105 check
"$expected" "$actual" 'ignore space'
107 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
113 # check that non-MIME messages aren't modified
115 run_test
'mhfixmsg first -outfile '"$actual" ''
116 check
"`mhpath first`" "$actual" 'keep first'
119 # check that non-MIME messages with no bodies aren't modified
121 cat >`mhpath new` <<EOF
122 From: Test <test@example.com>
123 To: Some User <user@example.com>
124 Date: Fri, 29 Sep 2006 00:00:00
125 Message-Id: @test.nmh
126 Subject: message with no body
129 run_test
'mhfixmsg last -outfile '"$actual" ''
130 check
"`mhpath last`" "$actual"
134 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
137 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
138 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
140 Content-Type: MULTIPART/MIXED;
141 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
142 Content-Transfer-Encoding: QUOTED-PRINTABLE
144 This message is in MIME format. The first part should be readable
146 while the remaining parts are likely unreadable without MIME-aware
149 ------=_NextPart_000_0000_00000000.00000000
150 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
151 Content-Transfer-Encoding: 8BIT
153 Some text in swedish.
155 Varf=C3=B6r inte anv=C3=A4nda...
157 ------=_NextPart_000_0000_00000000.00000000--
159 And some text after the last part.
162 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
164 run_test
'mhfixmsg last -nofixcte' ''
165 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
168 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
170 cat >"$expected" <<EOF
173 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
174 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
176 Content-Type: MULTIPART/MIXED;
177 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
178 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
179 Content-Transfer-Encoding: 8bit
181 This message is in MIME format. The first part should be readable
183 while the remaining parts are likely unreadable without MIME-aware
186 ------=_NextPart_000_0000_00000000.00000000
187 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
188 Content-Transfer-Encoding: 8BIT
190 Some text in swedish.
192 Varf=C3=B6r inte anv=C3=A4nda...
194 ------=_NextPart_000_0000_00000000.00000000--
196 And some text after the last part.
199 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
200 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
201 QUOTED-PRINTABLE with 8 bit"
202 check
"$expected" "$actual" 'keep first'
205 # check with no options: checks backup
206 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
207 folder last
>/dev
/null
208 run_test
'mhfixmsg' ''
209 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
210 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
211 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
214 # check backup with -file
215 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
216 folder last
>/dev
/null
217 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
218 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
219 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
222 # check -reformat (enabled by default): addition of text/plain part
223 # to solitary text/html part
225 cat >"$expected" <<EOF
227 From: sender@example.com
228 To: bonquiqui@example.com
230 Date: Sat, 26 Jan 2013 17:37:53 -0500
231 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
233 ------=_nmh-multipart
234 Content-Type: text/plain; charset="Windows-1252"
235 Content-Transfer-Encoding: 8bit
237 Need to go! Need ... to ... go!
239 ------=_nmh-multipart
240 Content-Type: text/html; charset="Windows-1252"
241 Content-Transfer-Encoding: 8bit
245 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
246 <meta name="Generator" content="Microsoft Exchange Server">
247 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
251 <div>Need to go! Need ... to ... go!</div>
255 ------=_nmh-multipart--
258 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
260 From: sender@example.com
261 To: bonquiqui@example.com
263 Date: Sat, 26 Jan 2013 17:37:53 -0500
264 Content-Type: text/html; charset="Windows-1252"
265 Content-Transfer-Encoding: quoted-printable
269 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
271 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
272 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
273 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
277 <div>Need to go! Need ... to ... go!</div>
282 if [ $can_reformat_texthtml -eq 1 ]; then
283 printf '%s\n' "mhfixmsg: 12, insert text/plain part
284 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
287 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
288 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
289 check
"$expected" "$actual"
290 check
"$expected.err" "$actual.err"
294 # check handling of boundary string that appears in message body
296 cat >"$expected" <<EOF
298 From: sender@example.com
299 To: bonquiqui@example.com
301 Date: Sat, 26 Jan 2013 17:37:53 -0500
302 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
304 ------=_nmh-multipart-3
305 Content-Type: text/plain; charset="Windows-1252"
306 Content-Transfer-Encoding: 8bit
308 ------=_nmh-multipart
309 ------=_nmh-multipart-1
310 ------=_nmh-multipart-2
312 ------=_nmh-multipart-3
313 Content-Type: text/html; charset="Windows-1252"
314 Content-Transfer-Encoding: 8bit
318 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
319 <meta name="Generator" content="Microsoft Exchange Server">
320 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
323 ------=_nmh-multipart<br>
324 ------=_nmh-multipart-1<br>
325 ------=_nmh-multipart-2<br>
329 ------=_nmh-multipart-3--
332 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
334 From: sender@example.com
335 To: bonquiqui@example.com
337 Date: Sat, 26 Jan 2013 17:37:53 -0500
338 Content-Type: text/html; charset="Windows-1252"
339 Content-Transfer-Encoding: quoted-printable
343 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
345 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
346 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
347 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
350 ------=3D_nmh-multipart<br>
351 ------=3D_nmh-multipart-1<br>
352 ------=3D_nmh-multipart-2<br>
357 if [ $can_reformat_texthtml -eq 1 ]; then
358 printf '%s\n' "mhfixmsg: 12, insert text/plain part
359 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
362 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
363 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
364 check
"$expected" "$actual"
365 check
"$expected.err" "$actual.err"
370 cat >"$expected" <<EOF
372 From: sender@example.com
373 To: bonquiqui@example.com
375 Date: Sat, 26 Jan 2013 17:37:53 -0500
376 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
378 ------=_nmh-multipart
379 Content-Type: text/plain; charset="Windows-1252"
380 Content-Transfer-Encoding: 8bit
382 Need to go! Need ... to ... go!
384 ------=_nmh-multipart
385 Content-Type: text/html; charset="Windows-1252"
386 Content-Transfer-Encoding: quoted-printable
390 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
392 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
393 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
394 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
398 <div>Need to go! Need ... to ... go!</div>
402 ------=_nmh-multipart--
405 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
407 From: sender@example.com
408 To: bonquiqui@example.com
410 Date: Sat, 26 Jan 2013 17:37:53 -0500
411 Content-Type: text/html; charset="Windows-1252"
412 Content-Transfer-Encoding: quoted-printable
416 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
418 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
419 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
420 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
424 <div>Need to go! Need ... to ... go!</div>
429 if [ $can_reformat_texthtml -eq 1 ]; then
430 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
432 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
433 mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | uniq >"$actual"
434 check
"$expected" "$actual"
435 check
"$expected.err" "$actual.err"
439 # check -decode (enabled by default)
440 cat >"$expected" <<EOF
441 To: recipient@example.com
442 From: sender@example.com
443 Subject: mhfixmsg decode test
445 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
447 ------- =_aaaaaaaaaa0
448 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
449 Content-Disposition: attachment; filename="test4.txt"
450 Content-Transfer-Encoding: 8bit
452 This is a text/plain part.
454 ------- =_aaaaaaaaaa0--
457 cat >`mhpath new` <<EOF
458 To: recipient@example.com
459 From: sender@example.com
460 Subject: mhfixmsg decode test
462 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
464 ------- =_aaaaaaaaaa0
465 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
466 Content-Disposition: attachment; filename="test4.txt"
467 Content-Transfer-Encoding: base64
469 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
471 ------- =_aaaaaaaaaa0--
474 mhfixmsg last
-outfile "$actual"
475 check
"$expected" "$actual"
478 # check -decode with more complicated content structure
480 To: recipient@example.com
481 From: sender@example.com
482 Subject: mhfixmsg decode test 2
484 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
486 This is additional content before the first subpart of the multipart.
488 ------- =_aaaaaaaaaa0
489 Content-Type: multipart/related;
490 type="multipart/alternative";
491 boundary="subpart__1.1"
494 Content-Type: text/plain; charset="iso-8859-1"
495 Content-Disposition: attachment; filename="test1.txt"
497 This is the first text/plain part, in a subpart.
501 This is additional content after the last subpart of the multipart.
503 ------- =_aaaaaaaaaa0
504 Content-Type: text/plain; charset="iso-8859-1"
505 Content-Disposition: attachment; filename="test2.txt"
506 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
507 Content-Transfer-Encoding: 8bit
509 This is the second text/plain part.
511 ------- =_aaaaaaaaaa0
512 Content-Type: text/plain; charset="iso-8859-1"
513 Content-Disposition: attachment; filename="test3.txt"
515 This is the third text/plain part.
517 ------- =_aaaaaaaaaa0
518 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
519 Content-Disposition: attachment; filename="test4.txt"
520 Content-Transfer-Encoding: 8bit
522 This is the fourth text/plain part.
524 ------- =_aaaaaaaaaa0--
526 This is additional content after the last subpart of the multipart.
529 cat >`mhpath new` <<EOF
530 To: recipient@example.com
531 From: sender@example.com
532 Subject: mhfixmsg decode test 2
534 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
536 This is additional content before the first subpart of the multipart.
538 ------- =_aaaaaaaaaa0
539 Content-Type: multipart/related;
540 type="multipart/alternative";
541 boundary="subpart__1.1"
544 Content-Type: text/plain; charset="iso-8859-1"
545 Content-Disposition: attachment; filename="test1.txt"
547 This is the first text/plain part, in a subpart.
551 This is additional content after the last subpart of the multipart.
553 ------- =_aaaaaaaaaa0
554 Content-Type: text/plain; charset="iso-8859-1"
555 Content-Disposition: attachment; filename="test2.txt"
556 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
557 Content-Transfer-Encoding: quoted-printable
559 This is the second text/plain part.
561 ------- =_aaaaaaaaaa0
562 Content-Type: text/plain; charset="iso-8859-1"
563 Content-Disposition: attachment; filename="test3.txt"
565 This is the third text/plain part.
567 ------- =_aaaaaaaaaa0
568 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
569 Content-Disposition: attachment; filename="test4.txt"
570 Content-Transfer-Encoding: base64
572 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
574 ------- =_aaaaaaaaaa0--
576 This is additional content after the last subpart of the multipart.
578 mhfixmsg last
-outfile "$actual"
579 check
"$expected" "$actual"
582 # check attempted -decode of binary text
583 #### Generated the encoded text below with:
584 #### $ printf '\x0d\xbd\xb2=\xbc\n' | base64
585 cat >`mhpath new` <<EOF
586 To: recipient@example.com
587 From: sender@example.com
588 Subject: mhfixmsg attempted binary decode test
590 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
592 ------- =_aaaaaaaaaa0
593 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
594 Content-Transfer-Encoding: base64
598 ------- =_aaaaaaaaaa0--
601 cp -p `mhpath last` "$expected"
605 check
`mhpath last` "$expected" 'keep first'
608 # check -decode of binary text
609 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
610 From: sender@example.com
611 Subject: mhfixmsg binary decode test
613 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
615 ------- =_aaaaaaaaaa0
616 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"square.txt\"
617 Content-Transfer-Encoding: binary
621 ------- =_aaaaaaaaaa0--
623 ## output_content() in mhoutsbr.c can't handle binary content.
624 ## mhfixmsg last -decodetext binary -outfile "$actual"
625 ## check "$expected" "$actual"
630 # check that -reformat succeeds when decode of binary text fails
631 cat >"$expected" <<'EOF'
633 Date: Thu, 11 Apr 2013 02:47:08 -0700
635 From: <sender@example.com>
636 Subject: body requires binary encoding
637 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
639 ------=_nmh-multipart
640 Content-Type: text/plain; charset="ISO-8859-1"
641 Content-Transfer-Encoding: 8bit
646 Vehicle License Fee $1.84
649 ------=_nmh-multipart
650 Content-Type: text/html; charset="ISO-8859-1"
651 Content-Transfer-Encoding: quoted-printable
654 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
655 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
656 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td al=
657 ign=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333=
658 " size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica,=
659 sans-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td=
660 ><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helv=
661 etica, sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr=
662 ><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D=
663 "2"><strong>State Tax</strong></font></td><td height=3D"3"> </td><td =
664 align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#3333=
665 33" size=3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetic=
666 a, sans-serif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</s=
667 trong></font></td><td height=3D"3"> </td><td align=3D"right"><font fa=
668 ce=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</fo=
669 nt></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
670 #333333" size=3D"2"><strong>State Txn Tax</strong></font></td><td height=3D=
671 "3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica, sans-se=
672 rif" color=3D"#333333" size=3D"2">$6.00</font></td></tr>
677 ------=_nmh-multipart--
680 cat >`mhpath new` <<'EOF'
682 Content-Type: text/html; charset="ISO-8859-1"
683 Content-Transfer-Encoding: quoted-printable
684 Date: Thu, 11 Apr 2013 02:47:08 -0700
686 From: <sender@example.com>
687 Subject: body requires binary encoding
690 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
691 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
692 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
693 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
694 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
695 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
696 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
697 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
698 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
699 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
700 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
701 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
702 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
703 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
704 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
705 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
706 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
707 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
708 #333333" size=3D"2">$6.00</font></td></tr>
714 if [ $can_reformat_texthtml -eq 1 ]; then
715 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
716 mhfixmsg last
-outfile - | uniq >"$actual"
717 check
"$expected" "$actual" 'ignore space'
719 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
725 # Also checks preservation of attributes after one (charset) that is
727 cat >"$expected" <<EOF
728 To: recipient@example.com
729 From: sender@example.com
730 Subject: mhfixmsg textcodeset test
732 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
734 ------- =_aaaaaaaaaa0
735 Content-Type: text/plain; charset="utf-8"; name="square.txt"
736 Content-Disposition: attachment; filename="square.txt"
737 Content-Transfer-Encoding: 8bit
741 ------- =_aaaaaaaaaa0--
744 #### Generated the encoded text below with:
745 #### $ printf '\xbd\xb2=\xbc\n' | base64
746 cat >`mhpath new` <<EOF
747 To: recipient@example.com
748 From: sender@example.com
749 Subject: mhfixmsg textcodeset test
751 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
753 ------- =_aaaaaaaaaa0
754 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
755 Content-Disposition: attachment; filename="square.txt"
756 Content-Transfer-Encoding: base64
760 ------- =_aaaaaaaaaa0--
764 mhfixmsg last
-textcodeset utf-8
-outfile "$actual" 2>"$actual.err"
765 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
767 echo skipping
-textcodeset check because nmh was built without
iconv
768 rm -f "$expected" "$actual" "$actual.err"
770 check
"$expected" "$actual"
776 # check -nofixboundary
777 cat >"$expected" <<EOF
780 cat >`mhpath new` <<EOF
781 Date: Fri, 13 May 2011 08:21:12 -0500
782 Content-Type: multipart/alternative;
783 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
784 Content-Transfer-Encoding: 8bit
786 From: <sender@example.com>
787 To: <recipient@example.com>
788 Subject: mhfixmsg bad boundary test
790 This is a multi-part message in MIME format.
792 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
793 Content-Type: text/plain
795 The boundaries of this part don't match the header boundary.
797 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
800 cp -p `mhpath last` `mhpath new`
802 run_test
'mhfixmsg last -nofixboundary' ''
803 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
806 # check that message is not output when fed through stdin
807 mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
808 check
"$expected" "$actual"
809 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
810 "$actual.err" >/dev
/null
; then
813 echo "$0: test failed, output is in $actual.err."
814 failed
=`expr ${failed:-0} + 1`
818 # check fixup of erroneous boundary in multipart (-fixboundary,
819 # enabled by default)
821 cat >"$expected" <<EOF
822 Date: Fri, 13 May 2011 08:21:12 -0500
823 Content-Type: multipart/alternative;
824 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
825 Content-Transfer-Encoding: 8bit
827 From: <sender@example.com>
828 To: <recipient@example.com>
829 Subject: mhfixmsg bad boundary test
831 This is a multi-part message in MIME format.
833 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
834 Content-Type: text/plain
836 The boundaries of this part don't match the header boundary.
838 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
841 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
842 "mhfixmsg: 17, fix multipart boundary"
843 check
"$expected" "$actual"
846 # check that text/plain part is added to lone text/html in multipart/related
847 cat >"$expected" <<EOF
849 Date: Tue, 26 Feb 2013 18:07:20 -0600
850 Subject: multipart/related, not /alternative
851 Content-Type: multipart/related;
852 boundary="----=_Part_90310_101292502.1"
854 ------=_Part_90310_101292502.1
855 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
857 ------=_nmh-multipart1
858 Content-Type: text/plain; charset="us-ascii"
859 Content-Transfer-Encoding: 7bit
861 This is the real content.
863 ------=_nmh-multipart1
864 Content-Type: text/html; charset="us-ascii"
865 Content-Transfer-Encoding: 7bit
868 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
869 <title>HTML Content</title>
872 This is the real content.
876 ------=_nmh-multipart1--
878 ------=_Part_90310_101292502.1
879 Content-Type: text/plain; charset="us-ascii"
880 Content-Transfer-Encoding: 7bit
882 Your email client does not support HTML messages
884 ------=_Part_90310_101292502.1--
887 cat >`mhpath new` <<EOF
889 Date: Tue, 26 Feb 2013 18:07:20 -0600
890 Subject: multipart/related, not /alternative
891 Content-Type: multipart/related;
892 boundary="----=_Part_90310_101292502.1"
894 ------=_Part_90310_101292502.1
895 Content-Type: text/html; charset="us-ascii"
896 Content-Transfer-Encoding: 7bit
899 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
900 <title>HTML Content</title>
903 This is the real content.
906 ------=_Part_90310_101292502.1
907 Content-Type: text/plain; charset="us-ascii"
908 Content-Transfer-Encoding: 7bit
910 Your email client does not support HTML messages
911 ------=_Part_90310_101292502.1--
914 if [ $can_reformat_texthtml -eq 1 ]; then
915 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
916 mhfixmsg last
-outfile - | uniq >"$actual"
917 check
"$expected" "$actual"
923 # check handling of rfc822 message type
924 cat >"$expected" <<EOF
925 From: Test <test@example.com>
926 To: Some User <user@example.com>
927 Date: Fri, 29 Sep 2006 00:00:00
928 Message-Id: @test.nmh
929 Subject: message with message/rfc822 attachment
931 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
933 and some garbage before the attachment
935 ------- =_aaaaaaaaaa0
936 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
937 Content-Description: 1552
938 Content-Disposition: attachment; filename="1552"
940 From: Test <test@example.com>
941 To: <another_user@example.com>
942 Date: Thu, 28 Sep 2006 00:00:00
943 Message-Id: @test.nmh
944 Subject: message/rfc822 attachment
946 This is an RFC-822 message.
948 ------- =_aaaaaaaaaa0--
950 and some garbage at the end
953 cat >`mhpath new` <<EOF
954 From: Test <test@example.com>
955 To: Some User <user@example.com>
956 Date: Fri, 29 Sep 2006 00:00:00
957 Message-Id: @test.nmh
958 Subject: message with message/rfc822 attachment
960 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
962 and some garbage before the attachment
964 ------- =_aaaaaaaaaa0
965 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
966 Content-Description: 1552
967 Content-Disposition: attachment; filename="1552"
969 From: Test <test@example.com>
970 To: <another_user@example.com>
971 Date: Thu, 28 Sep 2006 00:00:00
972 Message-Id: @test.nmh
973 Subject: message/rfc822 attachment
975 This is an RFC-822 message.
977 ------- =_aaaaaaaaaa0--
979 and some garbage at the end
982 run_test
'mhfixmsg last -outfile '"$actual" ''
983 check
"$expected" "$actual"
986 # check stripping of CRs from ASCII text context
987 cat >"$expected" <<EOF
989 From: sender@example.com
990 To: recipient@example.com
991 Subject: message with CR's
992 Date: Mon, 29 Apr 2013 11:51:45 -0400
994 There are two CR-LF pairs at the end of this sentence.
998 cat >`mhpath new` <<'EOF'
1000 From: sender@example.com
1001 To: recipient@example.com
1002 Subject: message with CR's
1003 Date: Mon, 29 Apr 2013 11:51:45 -0400
1005 There are two CR-LF pairs at the end of this sentence.
1009 mhfixmsg last
-outfile "$actual"
1010 check
"$expected" "$actual"
1014 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1017 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1018 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1019 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1021 run_test
'mhfixmsg 15' ''
1022 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1023 "${MH_TEST_DIR}/Mail/inbox/15.original"
1027 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1029 run_test
'mhfixmsg 19 -normmproc'
1030 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1031 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1035 run_test
'mhfixmsg 20 -rmmproc true'
1036 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1037 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1038 failed
=`expr ${failed:-0} + 1`
1042 # make sure there are no tmp files left over
1043 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1045 cat >"$expected" <<EOF
1048 check
"$expected" "$actual"