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]
56 mhfixmsg
-help >"$actual" 2>&1
57 check
"$expected" "$actual"
61 # Verified same behavior as compiled mhfixmsg.
62 case `mhfixmsg -version` in
64 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
65 failed
=`expr ${failed:-0} + 1`;;
69 # check that non-MIME messages aren't modified
71 run_test
'mhfixmsg first -outfile '"$actual" ''
72 check
"`mhpath first`" "$actual" 'keep first'
75 # check that non-MIME messages with no bodies aren't modified
77 cat >`mhpath new` <<EOF
78 From: Test <test@example.com>
79 To: Some User <user@example.com>
80 Date: Fri, 29 Sep 2006 00:00:00
82 Subject: message with no body
85 run_test
'mhfixmsg last -outfile '"$actual" ''
86 check
"`mhpath last`" "$actual"
90 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
93 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
94 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
96 Content-Type: MULTIPART/MIXED;
97 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
98 Content-Transfer-Encoding: QUOTED-PRINTABLE
100 This message is in MIME format. The first part should be readable
102 while the remaining parts are likely unreadable without MIME-aware
105 ------=_NextPart_000_0000_00000000.00000000
106 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
107 Content-Transfer-Encoding: 8BIT
109 Some text in swedish.
111 Varf=C3=B6r inte anv=C3=A4nda...
113 ------=_NextPart_000_0000_00000000.00000000--
115 And some text after the last part.
118 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
120 run_test
'mhfixmsg last -nofixcte' ''
121 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
124 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
126 cat >"$expected" <<EOF
129 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
130 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
132 Content-Type: MULTIPART/MIXED;
133 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
134 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
135 Content-Transfer-Encoding: 8bit
137 This message is in MIME format. The first part should be readable
139 while the remaining parts are likely unreadable without MIME-aware
142 ------=_NextPart_000_0000_00000000.00000000
143 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
144 Content-Transfer-Encoding: 8BIT
146 Some text in swedish.
148 Varf=C3=B6r inte anv=C3=A4nda...
150 ------=_NextPart_000_0000_00000000.00000000--
152 And some text after the last part.
155 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
156 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
157 QUOTED-PRINTABLE with 8 bit"
158 check
"$expected" "$actual" 'keep first'
161 # check with no options: checks backup
162 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
163 folder last
>/dev
/null
164 run_test
'mhfixmsg' ''
165 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
166 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
167 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
170 # check backup with -file
171 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
172 folder last
>/dev
/null
173 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
174 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
175 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
178 # check -reformat (enabled by default): addition of text/plain part
179 # to solitary text/html part
181 cat >"$expected" <<EOF
183 From: sender@example.com
184 To: bonquiqui@example.com
186 Date: Sat, 26 Jan 2013 17:37:53 -0500
187 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
189 ------=_nmh-multipart
190 Content-Type: text/plain; charset="Windows-1252"
191 Content-Transfer-Encoding: 8bit
193 Need to go! Need ... to ... go!
195 ------=_nmh-multipart
196 Content-Type: text/html; charset="Windows-1252"
197 Content-Transfer-Encoding: 8bit
201 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
202 <meta name="Generator" content="Microsoft Exchange Server">
203 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
207 <div>Need to go! Need ... to ... go!</div>
211 ------=_nmh-multipart--
214 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
216 From: sender@example.com
217 To: bonquiqui@example.com
219 Date: Sat, 26 Jan 2013 17:37:53 -0500
220 Content-Type: text/html; charset="Windows-1252"
221 Content-Transfer-Encoding: quoted-printable
225 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
227 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
228 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
229 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
233 <div>Need to go! Need ... to ... go!</div>
238 if [ $can_reformat_texthtml -eq 1 ]; then
239 printf '%s\n' "mhfixmsg: 12, insert text/plain part
240 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
243 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
244 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
245 check
"$expected" "$actual"
246 check
"$expected.err" "$actual.err"
252 # check implicit -file with absolute pathname
253 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
256 # check handling of boundary string that appears in message body
258 cat >"$expected" <<EOF
260 From: sender@example.com
261 To: bonquiqui@example.com
263 Date: Sat, 26 Jan 2013 17:37:53 -0500
264 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
266 ------=_nmh-multipart-3
267 Content-Type: text/plain; charset="Windows-1252"
268 Content-Transfer-Encoding: 8bit
270 ------=_nmh-multipart
271 ------=_nmh-multipart-1
272 ------=_nmh-multipart-2
274 ------=_nmh-multipart-3
275 Content-Type: text/html; charset="Windows-1252"
276 Content-Transfer-Encoding: 8bit
280 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
281 <meta name="Generator" content="Microsoft Exchange Server">
282 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
285 ------=_nmh-multipart<br>
286 ------=_nmh-multipart-1<br>
287 ------=_nmh-multipart-2<br>
291 ------=_nmh-multipart-3--
294 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
296 From: sender@example.com
297 To: bonquiqui@example.com
299 Date: Sat, 26 Jan 2013 17:37:53 -0500
300 Content-Type: text/html; charset="Windows-1252"
301 Content-Transfer-Encoding: quoted-printable
305 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
307 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
308 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
309 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
312 ------=3D_nmh-multipart<br>
313 ------=3D_nmh-multipart-1<br>
314 ------=3D_nmh-multipart-2<br>
319 if [ $can_reformat_texthtml -eq 1 ]; then
320 printf '%s\n' "mhfixmsg: 12, insert text/plain part
321 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
324 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
325 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
326 check
"$expected" "$actual"
327 check
"$expected.err" "$actual.err"
334 cat >"$expected" <<EOF
336 From: sender@example.com
337 To: bonquiqui@example.com
339 Date: Sat, 26 Jan 2013 17:37:53 -0500
340 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
342 ------=_nmh-multipart
343 Content-Type: text/plain; charset="Windows-1252"
344 Content-Transfer-Encoding: 8bit
346 Need to go! Need ... to ... go!
348 ------=_nmh-multipart
349 Content-Type: text/html; charset="Windows-1252"
350 Content-Transfer-Encoding: quoted-printable
354 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
356 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
357 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
358 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
362 <div>Need to go! Need ... to ... go!</div>
366 ------=_nmh-multipart--
369 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
371 From: sender@example.com
372 To: bonquiqui@example.com
374 Date: Sat, 26 Jan 2013 17:37:53 -0500
375 Content-Type: text/html; charset="Windows-1252"
376 Content-Transfer-Encoding: quoted-printable
380 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
382 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
383 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
384 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
388 <div>Need to go! Need ... to ... go!</div>
393 if [ $can_reformat_texthtml -eq 1 ]; then
394 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
396 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
397 mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | uniq >"$actual"
398 check
"$expected" "$actual"
399 check
"$expected.err" "$actual.err"
405 # check -decode (enabled by default)
406 cat >"$expected" <<EOF
407 To: recipient@example.com
408 From: sender@example.com
409 Subject: mhfixmsg decode test
411 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
413 ------- =_aaaaaaaaaa0
414 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
415 Content-Disposition: attachment; filename="test4.txt"
416 Content-Transfer-Encoding: 8bit
418 This is a text/plain part.
420 ------- =_aaaaaaaaaa0--
423 cat >`mhpath new` <<EOF
424 To: recipient@example.com
425 From: sender@example.com
426 Subject: mhfixmsg decode test
428 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
430 ------- =_aaaaaaaaaa0
431 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
432 Content-Disposition: attachment; filename="test4.txt"
433 Content-Transfer-Encoding: base64
435 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
437 ------- =_aaaaaaaaaa0--
440 mhfixmsg last
-outfile "$actual"
441 check
"$expected" "$actual"
444 # check -decode with more complicated content structure
446 To: recipient@example.com
447 From: sender@example.com
448 Subject: mhfixmsg decode test 2
450 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
452 This is additional content before the first subpart of the multipart.
454 ------- =_aaaaaaaaaa0
455 Content-Type: multipart/related;
456 type="multipart/alternative";
457 boundary="subpart__1.1"
460 Content-Type: text/plain; charset="iso-8859-1"
461 Content-Disposition: attachment; filename="test1.txt"
463 This is the first text/plain part, in a subpart.
467 This is additional content after the last subpart of the multipart.
469 ------- =_aaaaaaaaaa0
470 Content-Type: text/plain; charset="iso-8859-1"
471 Content-Disposition: attachment; filename="test2.txt"
472 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
473 Content-Transfer-Encoding: 8bit
475 This is the second text/plain part.
477 ------- =_aaaaaaaaaa0
478 Content-Type: text/plain; charset="iso-8859-1"
479 Content-Disposition: attachment; filename="test3.txt"
481 This is the third text/plain part.
483 ------- =_aaaaaaaaaa0
484 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
485 Content-Disposition: attachment; filename="test4.txt"
486 Content-Transfer-Encoding: 8bit
488 This is the fourth text/plain part.
490 ------- =_aaaaaaaaaa0--
492 This is additional content after the last subpart of the multipart.
495 cat >`mhpath new` <<EOF
496 To: recipient@example.com
497 From: sender@example.com
498 Subject: mhfixmsg decode test 2
500 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
502 This is additional content before the first subpart of the multipart.
504 ------- =_aaaaaaaaaa0
505 Content-Type: multipart/related;
506 type="multipart/alternative";
507 boundary="subpart__1.1"
510 Content-Type: text/plain; charset="iso-8859-1"
511 Content-Disposition: attachment; filename="test1.txt"
513 This is the first text/plain part, in a subpart.
517 This is additional content after the last subpart of the multipart.
519 ------- =_aaaaaaaaaa0
520 Content-Type: text/plain; charset="iso-8859-1"
521 Content-Disposition: attachment; filename="test2.txt"
522 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
523 Content-Transfer-Encoding: quoted-printable
525 This is the second text/plain part.
527 ------- =_aaaaaaaaaa0
528 Content-Type: text/plain; charset="iso-8859-1"
529 Content-Disposition: attachment; filename="test3.txt"
531 This is the third text/plain part.
533 ------- =_aaaaaaaaaa0
534 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
535 Content-Disposition: attachment; filename="test4.txt"
536 Content-Transfer-Encoding: base64
538 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
540 ------- =_aaaaaaaaaa0--
542 This is additional content after the last subpart of the multipart.
544 mhfixmsg last
-outfile "$actual"
545 check
"$expected" "$actual"
548 # check attempted -decode of binary text
549 #### Generated the encoded text below with:
550 #### $ printf '\x0d\xbd\xb2=\xbc\n' | base64
551 cat >`mhpath new` <<EOF
552 To: recipient@example.com
553 From: sender@example.com
554 Subject: mhfixmsg attempted binary decode test
556 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
558 ------- =_aaaaaaaaaa0
559 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
560 Content-Transfer-Encoding: base64
564 ------- =_aaaaaaaaaa0--
567 cp -p `mhpath last` "$expected"
571 check
`mhpath last` "$expected" 'keep first'
574 # check -decode of binary text
575 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
576 From: sender@example.com
577 Subject: mhfixmsg binary decode test
579 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
581 ------- =_aaaaaaaaaa0
582 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"square.txt\"
583 Content-Transfer-Encoding: binary
587 ------- =_aaaaaaaaaa0--
589 ## output_content() in mhoutsbr.c can't handle binary content.
590 ## mhfixmsg last -decodetext binary -outfile "$actual"
591 ## check "$expected" "$actual"
596 # check that -reformat succeeds when decode of binary text fails
597 cat >"$expected" <<'EOF'
599 Date: Thu, 11 Apr 2013 02:47:08 -0700
601 From: <sender@example.com>
602 Subject: body requires binary encoding
603 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
605 ------=_nmh-multipart
606 Content-Type: text/plain; charset="ISO-8859-1"
607 Content-Transfer-Encoding: 8bit
612 Vehicle License Fee $1.84
615 ------=_nmh-multipart
616 Content-Type: text/html; charset="ISO-8859-1"
617 Content-Transfer-Encoding: quoted-printable
622 cat >`mhpath new` <<'EOF'
624 Content-Type: text/html; charset="ISO-8859-1"
625 Content-Transfer-Encoding: quoted-printable
626 Date: Thu, 11 Apr 2013 02:47:08 -0700
628 From: <sender@example.com>
629 Subject: body requires binary encoding
632 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
633 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
634 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
635 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
636 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
637 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
638 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
639 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
640 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
641 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
642 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
643 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
644 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
645 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
646 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
647 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
648 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
649 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
650 #333333" size=3D"2">$6.00</font></td></tr>
656 if [ $can_reformat_texthtml -eq 1 ]; then
657 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
658 #### Truncate to avoid comparing the html portion because it can
659 #### get reformatted.
660 mhfixmsg last
-outfile - | uniq | head -22 >"$actual"
661 check
"$expected" "$actual" 'ignore space'
663 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
669 # Also checks preservation of attributes after one (charset) that is
671 cat >"$expected" <<EOF
672 To: recipient@example.com
673 From: sender@example.com
674 Subject: mhfixmsg textcodeset test
676 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
678 ------- =_aaaaaaaaaa0
679 Content-Type: text/plain; charset="utf-8"; name="square.txt"
680 Content-Disposition: attachment; filename="square.txt"
681 Content-Transfer-Encoding: 8bit
685 ------- =_aaaaaaaaaa0--
688 #### Generated the encoded text below with:
689 #### $ printf '\xbd\xb2=\xbc\n' | base64
690 cat >`mhpath new` <<EOF
691 To: recipient@example.com
692 From: sender@example.com
693 Subject: mhfixmsg textcodeset test
695 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
697 ------- =_aaaaaaaaaa0
698 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
699 Content-Disposition: attachment; filename="square.txt"
700 Content-Transfer-Encoding: base64
704 ------- =_aaaaaaaaaa0--
708 mhfixmsg last
-textcodeset utf
-8 -outfile "$actual" 2>"$actual.err"
709 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
711 echo "$0: skipping -textcodeset check because nmh was built without iconv"
712 rm -f "$expected" "$actual" "$actual.err"
714 check
"$expected" "$actual"
720 # check -nofixboundary
721 cat >"$expected" <<EOF
724 cat >`mhpath new` <<EOF
725 Date: Fri, 13 May 2011 08:21:12 -0500
726 Content-Type: multipart/alternative;
727 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
728 Content-Transfer-Encoding: 8bit
730 From: <sender@example.com>
731 To: <recipient@example.com>
732 Subject: mhfixmsg bad boundary test
734 This is a multi-part message in MIME format.
736 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
737 Content-Type: text/plain
739 The boundaries of this part don't match the header boundary.
741 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
744 cp -p `mhpath last` `mhpath new`
746 run_test
'mhfixmsg last -nofixboundary' ''
747 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
750 # check that message is not output when fed through stdin
751 mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
752 check
"$expected" "$actual"
753 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
754 "$actual.err" >/dev
/null
; then
757 echo "$0: test failed, output is in $actual.err."
758 failed
=`expr ${failed:-0} + 1`
762 # check fixup of erroneous boundary in multipart (-fixboundary,
763 # enabled by default)
765 cat >"$expected" <<EOF
766 Date: Fri, 13 May 2011 08:21:12 -0500
767 Content-Type: multipart/alternative;
768 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
769 Content-Transfer-Encoding: 8bit
771 From: <sender@example.com>
772 To: <recipient@example.com>
773 Subject: mhfixmsg bad boundary test
775 This is a multi-part message in MIME format.
777 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
778 Content-Type: text/plain
780 The boundaries of this part don't match the header boundary.
782 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
785 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
786 "mhfixmsg: 17, fix multipart boundary"
787 check
"$expected" "$actual"
790 # check that text/plain part is added to lone text/html in multipart/related
791 cat >"$expected" <<EOF
793 Date: Tue, 26 Feb 2013 18:07:20 -0600
794 Subject: multipart/related, not /alternative
795 Content-Type: multipart/related;
796 boundary="----=_Part_90310_101292502.1"
798 ------=_Part_90310_101292502.1
799 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
801 ------=_nmh-multipart1
802 Content-Type: text/plain; charset="us-ascii"
803 Content-Transfer-Encoding: 7bit
805 This is the real content.
807 ------=_nmh-multipart1
808 Content-Type: text/html; charset="us-ascii"
809 Content-Transfer-Encoding: 7bit
812 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
813 <title>HTML Content</title>
816 This is the real content.
820 ------=_nmh-multipart1--
822 ------=_Part_90310_101292502.1
823 Content-Type: text/plain; charset="us-ascii"
824 Content-Transfer-Encoding: 7bit
826 Your email client does not support HTML messages
828 ------=_Part_90310_101292502.1--
831 cat >`mhpath new` <<EOF
833 Date: Tue, 26 Feb 2013 18:07:20 -0600
834 Subject: multipart/related, not /alternative
835 Content-Type: multipart/related;
836 boundary="----=_Part_90310_101292502.1"
838 ------=_Part_90310_101292502.1
839 Content-Type: text/html; charset="us-ascii"
840 Content-Transfer-Encoding: 7bit
843 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
844 <title>HTML Content</title>
847 This is the real content.
850 ------=_Part_90310_101292502.1
851 Content-Type: text/plain; charset="us-ascii"
852 Content-Transfer-Encoding: 7bit
854 Your email client does not support HTML messages
855 ------=_Part_90310_101292502.1--
858 if [ $can_reformat_texthtml -eq 1 ]; then
859 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
860 mhfixmsg last
-outfile - | uniq >"$actual"
861 check
"$expected" "$actual"
867 # check handling of rfc822 message type
868 cat >"$expected" <<EOF
869 From: Test <test@example.com>
870 To: Some User <user@example.com>
871 Date: Fri, 29 Sep 2006 00:00:00
872 Message-Id: @test.nmh
873 Subject: message with message/rfc822 attachment
875 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
877 and some garbage before the attachment
879 ------- =_aaaaaaaaaa0
880 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
881 Content-Description: 1552
882 Content-Disposition: attachment; filename="1552"
884 From: Test <test@example.com>
885 To: <another_user@example.com>
886 Date: Thu, 28 Sep 2006 00:00:00
887 Message-Id: @test.nmh
888 Subject: message/rfc822 attachment
890 This is an RFC-822 message.
892 ------- =_aaaaaaaaaa0--
894 and some garbage at the end
897 cat >`mhpath new` <<EOF
898 From: Test <test@example.com>
899 To: Some User <user@example.com>
900 Date: Fri, 29 Sep 2006 00:00:00
901 Message-Id: @test.nmh
902 Subject: message with message/rfc822 attachment
904 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
906 and some garbage before the attachment
908 ------- =_aaaaaaaaaa0
909 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
910 Content-Description: 1552
911 Content-Disposition: attachment; filename="1552"
913 From: Test <test@example.com>
914 To: <another_user@example.com>
915 Date: Thu, 28 Sep 2006 00:00:00
916 Message-Id: @test.nmh
917 Subject: message/rfc822 attachment
919 This is an RFC-822 message.
921 ------- =_aaaaaaaaaa0--
923 and some garbage at the end
926 run_test
'mhfixmsg last -outfile '"$actual" ''
927 check
"$expected" "$actual"
930 # check stripping of CRs from ASCII text context
931 cat >"$expected" <<EOF
933 From: sender@example.com
934 To: recipient@example.com
935 Subject: message with CR's
936 Date: Mon, 29 Apr 2013 11:51:45 -0400
938 There are two CR-LF pairs at the end of this sentence.
942 cat >`mhpath new` <<'EOF'
944 From: sender@example.com
945 To: recipient@example.com
946 Subject: message with CR's
947 Date: Mon, 29 Apr 2013 11:51:45 -0400
949 There are two CR-LF pairs at the end of this sentence.
953 mhfixmsg last
-outfile "$actual"
954 check
"$expected" "$actual"
957 # check -replacetextplain
958 cat >"$expected" <<EOF
959 To: recipient@example.com
960 From: sender@example.com
961 Subject: mhfixmsg replacement of bad text/plain part test
963 Content-Type: multipart/alternative; boundary="----=_Part_876302"
966 Content-Type: text/plain; charset="UTF-8"
967 Content-Transfer-Encoding: 8bit
969 Yes, the text/plain part really was empty.
972 Content-Type: text/html; charset="UTF-8"
973 Content-Transfer-Encoding: 8bit
974 Content-Disposition: inline
977 <title>eticket</title>
980 Yes, the text/plain part really was empty.
984 ------=_Part_876302--
987 cat >`mhpath new` <<'EOF'
988 To: recipient@example.com
989 From: sender@example.com
990 Subject: mhfixmsg replacement of bad text/plain part test
992 Content-Type: multipart/alternative; boundary="----=_Part_876302"
995 Content-Type: text/plain; charset="iso-8859-15"
996 Content-Transfer-Encoding: 7bit
997 Content-Disposition: inline
1002 Content-Type: text/html; charset="UTF-8"
1003 Content-Transfer-Encoding: 8bit
1004 Content-Disposition: inline
1007 <title>eticket</title>
1010 Yes, the text/plain part really was empty.
1014 ------=_Part_876302--
1017 if [ $can_reformat_texthtml -eq 1 ]; then
1018 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
1019 mhfixmsg last
-replacetextplain -outfile - | uniq > "$actual"
1020 check
"$expected" "$actual"
1026 # check -noreplacetextplain
1027 cat >"$expected" <<EOF
1028 To: recipient@example.com
1029 From: sender@example.com
1030 Subject: mhfixmsg replacement of bad text/plain part test
1032 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1035 Content-Type: text/plain; charset="iso-8859-15"
1036 Content-Transfer-Encoding: 7bit
1037 Content-Disposition: inline
1042 Content-Type: text/html; charset="UTF-8"
1043 Content-Transfer-Encoding: 8bit
1044 Content-Disposition: inline
1047 <title>eticket</title>
1050 Yes, the text/plain part really was empty.
1054 ------=_Part_876302--
1057 mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1058 check
"$expected" "$actual"
1062 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1065 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1066 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1067 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1069 run_test
'mhfixmsg 15' ''
1070 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1071 "${MH_TEST_DIR}/Mail/inbox/15.original"
1075 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1077 run_test
'mhfixmsg 19 -normmproc'
1078 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1079 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1083 run_test
'mhfixmsg 20 -rmmproc true'
1084 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1085 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1086 failed
=`expr ${failed:-0} + 1`
1090 # make sure there are no tmp files left over
1091 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1093 cat >"$expected" <<EOF
1096 check
"$expected" "$actual"