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 # check that non-MIME messages aren't modified
70 run_test
'mhfixmsg first -outfile '"$actual" ''
71 check
"`mhpath first`" "$actual" 'keep first'
74 # check that non-MIME messages with no bodies aren't modified
76 cat >`mhpath new` <<EOF
77 From: Test <test@example.com>
78 To: Some User <user@example.com>
79 Date: Fri, 29 Sep 2006 00:00:00
81 Subject: message with no body
84 run_test
'mhfixmsg last -outfile '"$actual" ''
85 check
"`mhpath last`" "$actual"
89 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
92 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
93 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
95 Content-Type: MULTIPART/MIXED;
96 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
97 Content-Transfer-Encoding: QUOTED-PRINTABLE
99 This message is in MIME format. The first part should be readable
101 while the remaining parts are likely unreadable without MIME-aware
104 ------=_NextPart_000_0000_00000000.00000000
105 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
106 Content-Transfer-Encoding: 8BIT
108 Some text in swedish.
110 Varf=C3=B6r inte anv=C3=A4nda...
112 ------=_NextPart_000_0000_00000000.00000000--
114 And some text after the last part.
117 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
119 run_test
'mhfixmsg last -nofixcte' ''
120 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
123 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
125 cat >"$expected" <<EOF
128 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
129 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
131 Content-Type: MULTIPART/MIXED;
132 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
133 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
134 Content-Transfer-Encoding: 8bit
136 This message is in MIME format. The first part should be readable
138 while the remaining parts are likely unreadable without MIME-aware
141 ------=_NextPart_000_0000_00000000.00000000
142 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
143 Content-Transfer-Encoding: 8BIT
145 Some text in swedish.
147 Varf=C3=B6r inte anv=C3=A4nda...
149 ------=_NextPart_000_0000_00000000.00000000--
151 And some text after the last part.
154 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
155 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
156 QUOTED-PRINTABLE with 8 bit"
157 check
"$expected" "$actual" 'keep first'
160 # check with no options: checks backup
161 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
162 folder last
>/dev
/null
163 run_test
'mhfixmsg' ''
164 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
165 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
166 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
169 # check backup with -file
170 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
171 folder last
>/dev
/null
172 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
173 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
174 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
177 # check -reformat (enabled by default): addition of text/plain part
178 # to solitary text/html part
180 cat >"$expected" <<EOF
182 From: sender@example.com
183 To: bonquiqui@example.com
185 Date: Sat, 26 Jan 2013 17:37:53 -0500
186 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
188 ------=_nmh-multipart
189 Content-Type: text/plain; charset="Windows-1252"
190 Content-Transfer-Encoding: 8bit
192 Need to go! Need ... to ... go!
194 ------=_nmh-multipart
195 Content-Type: text/html; charset="Windows-1252"
196 Content-Transfer-Encoding: 8bit
200 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
201 <meta name="Generator" content="Microsoft Exchange Server">
202 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
206 <div>Need to go! Need ... to ... go!</div>
210 ------=_nmh-multipart--
213 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
215 From: sender@example.com
216 To: bonquiqui@example.com
218 Date: Sat, 26 Jan 2013 17:37:53 -0500
219 Content-Type: text/html; charset="Windows-1252"
220 Content-Transfer-Encoding: quoted-printable
224 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
226 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
227 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
228 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
232 <div>Need to go! Need ... to ... go!</div>
237 if [ $can_reformat_texthtml -eq 1 ]; then
238 printf '%s\n' "mhfixmsg: 12, insert text/plain part
239 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
242 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
243 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
244 check
"$expected" "$actual"
245 check
"$expected.err" "$actual.err"
249 # check handling of boundary string that appears in message body
251 cat >"$expected" <<EOF
253 From: sender@example.com
254 To: bonquiqui@example.com
256 Date: Sat, 26 Jan 2013 17:37:53 -0500
257 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
259 ------=_nmh-multipart-3
260 Content-Type: text/plain; charset="Windows-1252"
261 Content-Transfer-Encoding: 8bit
263 ------=_nmh-multipart
264 ------=_nmh-multipart-1
265 ------=_nmh-multipart-2
267 ------=_nmh-multipart-3
268 Content-Type: text/html; charset="Windows-1252"
269 Content-Transfer-Encoding: 8bit
273 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
274 <meta name="Generator" content="Microsoft Exchange Server">
275 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
278 ------=_nmh-multipart<br>
279 ------=_nmh-multipart-1<br>
280 ------=_nmh-multipart-2<br>
284 ------=_nmh-multipart-3--
287 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
289 From: sender@example.com
290 To: bonquiqui@example.com
292 Date: Sat, 26 Jan 2013 17:37:53 -0500
293 Content-Type: text/html; charset="Windows-1252"
294 Content-Transfer-Encoding: quoted-printable
298 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
300 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
301 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
302 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
305 ------=3D_nmh-multipart<br>
306 ------=3D_nmh-multipart-1<br>
307 ------=3D_nmh-multipart-2<br>
312 if [ $can_reformat_texthtml -eq 1 ]; then
313 printf '%s\n' "mhfixmsg: 12, insert text/plain part
314 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
317 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
318 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
319 check
"$expected" "$actual"
320 check
"$expected.err" "$actual.err"
325 cat >"$expected" <<EOF
327 From: sender@example.com
328 To: bonquiqui@example.com
330 Date: Sat, 26 Jan 2013 17:37:53 -0500
331 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
333 ------=_nmh-multipart
334 Content-Type: text/plain; charset="Windows-1252"
335 Content-Transfer-Encoding: 8bit
337 Need to go! Need ... to ... go!
339 ------=_nmh-multipart
340 Content-Type: text/html; charset="Windows-1252"
341 Content-Transfer-Encoding: quoted-printable
345 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
347 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
348 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
349 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
353 <div>Need to go! Need ... to ... go!</div>
357 ------=_nmh-multipart--
360 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
362 From: sender@example.com
363 To: bonquiqui@example.com
365 Date: Sat, 26 Jan 2013 17:37:53 -0500
366 Content-Type: text/html; charset="Windows-1252"
367 Content-Transfer-Encoding: quoted-printable
371 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
373 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
374 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
375 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
379 <div>Need to go! Need ... to ... go!</div>
384 if [ $can_reformat_texthtml -eq 1 ]; then
385 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
387 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
388 mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | uniq >"$actual"
389 check
"$expected" "$actual"
390 check
"$expected.err" "$actual.err"
394 # check -decode (enabled by default)
395 cat >"$expected" <<EOF
396 To: recipient@example.com
397 From: sender@example.com
398 Subject: mhfixmsg decode test
400 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
402 ------- =_aaaaaaaaaa0
403 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
404 Content-Disposition: attachment; filename="test4.txt"
405 Content-Transfer-Encoding: 8bit
407 This is a text/plain part.
409 ------- =_aaaaaaaaaa0--
412 cat >`mhpath new` <<EOF
413 To: recipient@example.com
414 From: sender@example.com
415 Subject: mhfixmsg decode test
417 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
419 ------- =_aaaaaaaaaa0
420 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
421 Content-Disposition: attachment; filename="test4.txt"
422 Content-Transfer-Encoding: base64
424 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
426 ------- =_aaaaaaaaaa0--
429 mhfixmsg last
-outfile "$actual"
430 check
"$expected" "$actual"
433 # check -decode with more complicated content structure
435 To: recipient@example.com
436 From: sender@example.com
437 Subject: mhfixmsg decode test 2
439 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
441 This is additional content before the first subpart of the multipart.
443 ------- =_aaaaaaaaaa0
444 Content-Type: multipart/related;
445 type="multipart/alternative";
446 boundary="subpart__1.1"
449 Content-Type: text/plain; charset="iso-8859-1"
450 Content-Disposition: attachment; filename="test1.txt"
452 This is the first text/plain part, in a subpart.
456 This is additional content after the last subpart of the multipart.
458 ------- =_aaaaaaaaaa0
459 Content-Type: text/plain; charset="iso-8859-1"
460 Content-Disposition: attachment; filename="test2.txt"
461 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
462 Content-Transfer-Encoding: 8bit
464 This is the second text/plain part.
466 ------- =_aaaaaaaaaa0
467 Content-Type: text/plain; charset="iso-8859-1"
468 Content-Disposition: attachment; filename="test3.txt"
470 This is the third text/plain part.
472 ------- =_aaaaaaaaaa0
473 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
474 Content-Disposition: attachment; filename="test4.txt"
475 Content-Transfer-Encoding: 8bit
477 This is the fourth text/plain part.
479 ------- =_aaaaaaaaaa0--
481 This is additional content after the last subpart of the multipart.
484 cat >`mhpath new` <<EOF
485 To: recipient@example.com
486 From: sender@example.com
487 Subject: mhfixmsg decode test 2
489 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
491 This is additional content before the first subpart of the multipart.
493 ------- =_aaaaaaaaaa0
494 Content-Type: multipart/related;
495 type="multipart/alternative";
496 boundary="subpart__1.1"
499 Content-Type: text/plain; charset="iso-8859-1"
500 Content-Disposition: attachment; filename="test1.txt"
502 This is the first text/plain part, in a subpart.
506 This is additional content after the last subpart of the multipart.
508 ------- =_aaaaaaaaaa0
509 Content-Type: text/plain; charset="iso-8859-1"
510 Content-Disposition: attachment; filename="test2.txt"
511 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
512 Content-Transfer-Encoding: quoted-printable
514 This is the second text/plain part.
516 ------- =_aaaaaaaaaa0
517 Content-Type: text/plain; charset="iso-8859-1"
518 Content-Disposition: attachment; filename="test3.txt"
520 This is the third text/plain part.
522 ------- =_aaaaaaaaaa0
523 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
524 Content-Disposition: attachment; filename="test4.txt"
525 Content-Transfer-Encoding: base64
527 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
529 ------- =_aaaaaaaaaa0--
531 This is additional content after the last subpart of the multipart.
533 mhfixmsg last
-outfile "$actual"
534 check
"$expected" "$actual"
537 # check attempted -decode of binary text
538 #### Generated the encoded text below with:
539 #### $ printf '\x0d\xbd\xb2=\xbc\n' | base64
540 cat >`mhpath new` <<EOF
541 To: recipient@example.com
542 From: sender@example.com
543 Subject: mhfixmsg attempted binary decode test
545 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
547 ------- =_aaaaaaaaaa0
548 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
549 Content-Transfer-Encoding: base64
553 ------- =_aaaaaaaaaa0--
556 cp -p `mhpath last` "$expected"
560 check
`mhpath last` "$expected" 'keep first'
563 # check -decode of binary text
564 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
565 From: sender@example.com
566 Subject: mhfixmsg binary decode test
568 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
570 ------- =_aaaaaaaaaa0
571 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"square.txt\"
572 Content-Transfer-Encoding: binary
576 ------- =_aaaaaaaaaa0--
578 ## output_content() in mhoutsbr.c can't handle binary content.
579 ## mhfixmsg last -decodetext binary -outfile "$actual"
580 ## check "$expected" "$actual"
585 # check that -reformat succeeds when decode of binary text fails
586 cat >"$expected" <<'EOF'
588 Date: Thu, 11 Apr 2013 02:47:08 -0700
590 From: <sender@example.com>
591 Subject: body requires binary encoding
592 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
594 ------=_nmh-multipart
595 Content-Type: text/plain; charset="ISO-8859-1"
596 Content-Transfer-Encoding: 8bit
601 Vehicle License Fee $1.84
604 ------=_nmh-multipart
605 Content-Type: text/html; charset="ISO-8859-1"
606 Content-Transfer-Encoding: quoted-printable
609 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
610 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
611 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td al=
612 ign=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333=
613 " size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica,=
614 sans-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td=
615 ><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helv=
616 etica, sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr=
617 ><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D=
618 "2"><strong>State Tax</strong></font></td><td height=3D"3"> </td><td =
619 align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#3333=
620 33" size=3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetic=
621 a, sans-serif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</s=
622 trong></font></td><td height=3D"3"> </td><td align=3D"right"><font fa=
623 ce=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</fo=
624 nt></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
625 #333333" size=3D"2"><strong>State Txn Tax</strong></font></td><td height=3D=
626 "3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica, sans-se=
627 rif" color=3D"#333333" size=3D"2">$6.00</font></td></tr>
632 ------=_nmh-multipart--
635 cat >`mhpath new` <<'EOF'
637 Content-Type: text/html; charset="ISO-8859-1"
638 Content-Transfer-Encoding: quoted-printable
639 Date: Thu, 11 Apr 2013 02:47:08 -0700
641 From: <sender@example.com>
642 Subject: body requires binary encoding
645 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
646 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
647 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
648 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
649 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
650 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
651 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
652 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
653 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
654 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
655 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
656 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
657 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
658 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
659 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
660 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
661 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
662 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
663 #333333" size=3D"2">$6.00</font></td></tr>
669 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
670 mhfixmsg last
-outfile - | uniq >"$actual"
671 check
"$expected" "$actual" 'ignore space'
675 # Also checks preservation of attributes after one (charset) that is
677 cat >"$expected" <<EOF
678 To: recipient@example.com
679 From: sender@example.com
680 Subject: mhfixmsg textcodeset test
682 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
684 ------- =_aaaaaaaaaa0
685 Content-Type: text/plain; charset="utf-8"; name="square.txt"
686 Content-Disposition: attachment; filename="square.txt"
687 Content-Transfer-Encoding: 8bit
691 ------- =_aaaaaaaaaa0--
694 #### Generated the encoded text below with:
695 #### $ printf '\xbd\xb2=\xbc\n' | base64
696 cat >`mhpath new` <<EOF
697 To: recipient@example.com
698 From: sender@example.com
699 Subject: mhfixmsg textcodeset test
701 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
703 ------- =_aaaaaaaaaa0
704 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
705 Content-Disposition: attachment; filename="square.txt"
706 Content-Transfer-Encoding: base64
710 ------- =_aaaaaaaaaa0--
714 mhfixmsg last
-textcodeset utf
-8 -outfile "$actual" 2>"$actual.err"
715 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
717 echo skipping
-textcodeset check because nmh was built without
iconv
718 rm -f "$expected" "$actual" "$actual.err"
720 check
"$expected" "$actual"
726 # check -nofixboundary
727 cat >"$expected" <<EOF
730 cat >`mhpath new` <<EOF
731 Date: Fri, 13 May 2011 08:21:12 -0500
732 Content-Type: multipart/alternative;
733 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
734 Content-Transfer-Encoding: 8bit
736 From: <sender@example.com>
737 To: <recipient@example.com>
738 Subject: mhfixmsg bad boundary test
740 This is a multi-part message in MIME format.
742 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
743 Content-Type: text/plain
745 The boundaries of this part don't match the header boundary.
747 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
750 cp -p `mhpath last` `mhpath new`
752 run_test
'mhfixmsg last -nofixboundary' ''
753 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
756 # check that message is not output when fed through stdin
757 mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
758 check
"$expected" "$actual"
759 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
760 "$actual.err" >/dev
/null
; then
763 echo "$0: test failed, output is in $actual.err."
764 failed
=`expr ${failed:-0} + 1`
768 # check fixup of erroneous boundary in multipart (-fixboundary,
769 # enabled by default)
771 cat >"$expected" <<EOF
772 Date: Fri, 13 May 2011 08:21:12 -0500
773 Content-Type: multipart/alternative;
774 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
775 Content-Transfer-Encoding: 8bit
777 From: <sender@example.com>
778 To: <recipient@example.com>
779 Subject: mhfixmsg bad boundary test
781 This is a multi-part message in MIME format.
783 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
784 Content-Type: text/plain
786 The boundaries of this part don't match the header boundary.
788 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
791 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
792 "mhfixmsg: 17, fix multipart boundary"
793 check
"$expected" "$actual"
796 # check that text/plain part is added to lone text/html in multipart/related
797 cat >"$expected" <<EOF
799 Date: Tue, 26 Feb 2013 18:07:20 -0600
800 Subject: multipart/related, not /alternative
801 Content-Type: multipart/related;
802 boundary="----=_Part_90310_101292502.1"
804 ------=_Part_90310_101292502.1
805 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
807 ------=_nmh-multipart1
808 Content-Type: text/plain; charset="us-ascii"
809 Content-Transfer-Encoding: 7bit
811 This is the real content.
813 ------=_nmh-multipart1
814 Content-Type: text/html; charset="us-ascii"
815 Content-Transfer-Encoding: 7bit
818 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
819 <title>HTML Content</title>
822 This is the real content.
826 ------=_nmh-multipart1--
828 ------=_Part_90310_101292502.1
829 Content-Type: text/plain; charset="us-ascii"
830 Content-Transfer-Encoding: 7bit
832 Your email client does not support HTML messages
834 ------=_Part_90310_101292502.1--
837 cat >`mhpath new` <<EOF
839 Date: Tue, 26 Feb 2013 18:07:20 -0600
840 Subject: multipart/related, not /alternative
841 Content-Type: multipart/related;
842 boundary="----=_Part_90310_101292502.1"
844 ------=_Part_90310_101292502.1
845 Content-Type: text/html; charset="us-ascii"
846 Content-Transfer-Encoding: 7bit
849 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
850 <title>HTML Content</title>
853 This is the real content.
856 ------=_Part_90310_101292502.1
857 Content-Type: text/plain; charset="us-ascii"
858 Content-Transfer-Encoding: 7bit
860 Your email client does not support HTML messages
861 ------=_Part_90310_101292502.1--
864 if [ $can_reformat_texthtml -eq 1 ]; then
865 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
866 mhfixmsg last
-outfile - | uniq >"$actual"
867 check
"$expected" "$actual"
872 # check handling of rfc822 message type
873 cat >"$expected" <<EOF
874 From: Test <test@example.com>
875 To: Some User <user@example.com>
876 Date: Fri, 29 Sep 2006 00:00:00
877 Message-Id: @test.nmh
878 Subject: message with message/rfc822 attachment
880 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
882 and some garbage before the attachment
884 ------- =_aaaaaaaaaa0
885 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
886 Content-Description: 1552
887 Content-Disposition: attachment; filename="1552"
889 From: Test <test@example.com>
890 To: <another_user@example.com>
891 Date: Thu, 28 Sep 2006 00:00:00
892 Message-Id: @test.nmh
893 Subject: message/rfc822 attachment
895 This is an RFC-822 message.
897 ------- =_aaaaaaaaaa0--
899 and some garbage at the end
902 cat >`mhpath new` <<EOF
903 From: Test <test@example.com>
904 To: Some User <user@example.com>
905 Date: Fri, 29 Sep 2006 00:00:00
906 Message-Id: @test.nmh
907 Subject: message with message/rfc822 attachment
909 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
911 and some garbage before the attachment
913 ------- =_aaaaaaaaaa0
914 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
915 Content-Description: 1552
916 Content-Disposition: attachment; filename="1552"
918 From: Test <test@example.com>
919 To: <another_user@example.com>
920 Date: Thu, 28 Sep 2006 00:00:00
921 Message-Id: @test.nmh
922 Subject: message/rfc822 attachment
924 This is an RFC-822 message.
926 ------- =_aaaaaaaaaa0--
928 and some garbage at the end
931 run_test
'mhfixmsg last -outfile '"$actual" ''
932 check
"$expected" "$actual"
936 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
939 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
940 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
941 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
943 run_test
'mhfixmsg 15' ''
944 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
945 "${MH_TEST_DIR}/Mail/inbox/15.original"
949 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
951 run_test
'mhfixmsg 19 -normmproc'
952 check
"${MH_TEST_DIR}/Mail/inbox/20" \
953 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
957 run_test
'mhfixmsg 20 -rmmproc true'
958 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
959 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
960 failed
=`expr ${failed:-0} + 1`
964 # make sure there are no tmp files left over
965 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
967 cat >"$expected" <<EOF
970 check
"$expected" "$actual"