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"
250 # check handling of boundary string that appears in message body
252 cat >"$expected" <<EOF
254 From: sender@example.com
255 To: bonquiqui@example.com
257 Date: Sat, 26 Jan 2013 17:37:53 -0500
258 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
260 ------=_nmh-multipart-3
261 Content-Type: text/plain; charset="Windows-1252"
262 Content-Transfer-Encoding: 8bit
264 ------=_nmh-multipart
265 ------=_nmh-multipart-1
266 ------=_nmh-multipart-2
268 ------=_nmh-multipart-3
269 Content-Type: text/html; charset="Windows-1252"
270 Content-Transfer-Encoding: 8bit
274 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
275 <meta name="Generator" content="Microsoft Exchange Server">
276 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
279 ------=_nmh-multipart<br>
280 ------=_nmh-multipart-1<br>
281 ------=_nmh-multipart-2<br>
285 ------=_nmh-multipart-3--
288 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
290 From: sender@example.com
291 To: bonquiqui@example.com
293 Date: Sat, 26 Jan 2013 17:37:53 -0500
294 Content-Type: text/html; charset="Windows-1252"
295 Content-Transfer-Encoding: quoted-printable
299 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
301 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
302 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
303 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
306 ------=3D_nmh-multipart<br>
307 ------=3D_nmh-multipart-1<br>
308 ------=3D_nmh-multipart-2<br>
313 if [ $can_reformat_texthtml -eq 1 ]; then
314 printf '%s\n' "mhfixmsg: 12, insert text/plain part
315 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
318 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
319 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
320 check
"$expected" "$actual"
321 check
"$expected.err" "$actual.err"
326 cat >"$expected" <<EOF
328 From: sender@example.com
329 To: bonquiqui@example.com
331 Date: Sat, 26 Jan 2013 17:37:53 -0500
332 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
334 ------=_nmh-multipart
335 Content-Type: text/plain; charset="Windows-1252"
336 Content-Transfer-Encoding: 8bit
338 Need to go! Need ... to ... go!
340 ------=_nmh-multipart
341 Content-Type: text/html; charset="Windows-1252"
342 Content-Transfer-Encoding: quoted-printable
346 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
348 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
349 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
350 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
354 <div>Need to go! Need ... to ... go!</div>
358 ------=_nmh-multipart--
361 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
363 From: sender@example.com
364 To: bonquiqui@example.com
366 Date: Sat, 26 Jan 2013 17:37:53 -0500
367 Content-Type: text/html; charset="Windows-1252"
368 Content-Transfer-Encoding: quoted-printable
372 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
374 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
375 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
376 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
380 <div>Need to go! Need ... to ... go!</div>
385 if [ $can_reformat_texthtml -eq 1 ]; then
386 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
388 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
389 mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | uniq >"$actual"
390 check
"$expected" "$actual"
391 check
"$expected.err" "$actual.err"
395 # check -decode (enabled by default)
396 cat >"$expected" <<EOF
397 To: recipient@example.com
398 From: sender@example.com
399 Subject: mhfixmsg decode test
401 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
403 ------- =_aaaaaaaaaa0
404 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
405 Content-Disposition: attachment; filename="test4.txt"
406 Content-Transfer-Encoding: 8bit
408 This is a text/plain part.
410 ------- =_aaaaaaaaaa0--
413 cat >`mhpath new` <<EOF
414 To: recipient@example.com
415 From: sender@example.com
416 Subject: mhfixmsg decode test
418 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
420 ------- =_aaaaaaaaaa0
421 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
422 Content-Disposition: attachment; filename="test4.txt"
423 Content-Transfer-Encoding: base64
425 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
427 ------- =_aaaaaaaaaa0--
430 mhfixmsg last
-outfile "$actual"
431 check
"$expected" "$actual"
434 # check -decode with more complicated content structure
436 To: recipient@example.com
437 From: sender@example.com
438 Subject: mhfixmsg decode test 2
440 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
442 This is additional content before the first subpart of the multipart.
444 ------- =_aaaaaaaaaa0
445 Content-Type: multipart/related;
446 type="multipart/alternative";
447 boundary="subpart__1.1"
450 Content-Type: text/plain; charset="iso-8859-1"
451 Content-Disposition: attachment; filename="test1.txt"
453 This is the first text/plain part, in a subpart.
457 This is additional content after the last subpart of the multipart.
459 ------- =_aaaaaaaaaa0
460 Content-Type: text/plain; charset="iso-8859-1"
461 Content-Disposition: attachment; filename="test2.txt"
462 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
463 Content-Transfer-Encoding: 8bit
465 This is the second text/plain part.
467 ------- =_aaaaaaaaaa0
468 Content-Type: text/plain; charset="iso-8859-1"
469 Content-Disposition: attachment; filename="test3.txt"
471 This is the third text/plain part.
473 ------- =_aaaaaaaaaa0
474 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
475 Content-Disposition: attachment; filename="test4.txt"
476 Content-Transfer-Encoding: 8bit
478 This is the fourth text/plain part.
480 ------- =_aaaaaaaaaa0--
482 This is additional content after the last subpart of the multipart.
485 cat >`mhpath new` <<EOF
486 To: recipient@example.com
487 From: sender@example.com
488 Subject: mhfixmsg decode test 2
490 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
492 This is additional content before the first subpart of the multipart.
494 ------- =_aaaaaaaaaa0
495 Content-Type: multipart/related;
496 type="multipart/alternative";
497 boundary="subpart__1.1"
500 Content-Type: text/plain; charset="iso-8859-1"
501 Content-Disposition: attachment; filename="test1.txt"
503 This is the first text/plain part, in a subpart.
507 This is additional content after the last subpart of the multipart.
509 ------- =_aaaaaaaaaa0
510 Content-Type: text/plain; charset="iso-8859-1"
511 Content-Disposition: attachment; filename="test2.txt"
512 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
513 Content-Transfer-Encoding: quoted-printable
515 This is the second text/plain part.
517 ------- =_aaaaaaaaaa0
518 Content-Type: text/plain; charset="iso-8859-1"
519 Content-Disposition: attachment; filename="test3.txt"
521 This is the third text/plain part.
523 ------- =_aaaaaaaaaa0
524 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
525 Content-Disposition: attachment; filename="test4.txt"
526 Content-Transfer-Encoding: base64
528 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
530 ------- =_aaaaaaaaaa0--
532 This is additional content after the last subpart of the multipart.
534 mhfixmsg last
-outfile "$actual"
535 check
"$expected" "$actual"
538 # check attempted -decode of binary text
539 #### Generated the encoded text below with:
540 #### $ printf '\x0d\xbd\xb2=\xbc\n' | base64
541 cat >`mhpath new` <<EOF
542 To: recipient@example.com
543 From: sender@example.com
544 Subject: mhfixmsg attempted binary decode test
546 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
548 ------- =_aaaaaaaaaa0
549 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
550 Content-Transfer-Encoding: base64
554 ------- =_aaaaaaaaaa0--
557 cp -p `mhpath last` "$expected"
561 check
`mhpath last` "$expected" 'keep first'
564 # check -decode of binary text
565 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
566 From: sender@example.com
567 Subject: mhfixmsg binary decode test
569 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
571 ------- =_aaaaaaaaaa0
572 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"square.txt\"
573 Content-Transfer-Encoding: binary
577 ------- =_aaaaaaaaaa0--
579 ## output_content() in mhoutsbr.c can't handle binary content.
580 ## mhfixmsg last -decodetext binary -outfile "$actual"
581 ## check "$expected" "$actual"
586 # check that -reformat succeeds when decode of binary text fails
587 cat >"$expected" <<'EOF'
589 Date: Thu, 11 Apr 2013 02:47:08 -0700
591 From: <sender@example.com>
592 Subject: body requires binary encoding
593 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
595 ------=_nmh-multipart
596 Content-Type: text/plain; charset="ISO-8859-1"
597 Content-Transfer-Encoding: 8bit
602 Vehicle License Fee $1.84
605 ------=_nmh-multipart
606 Content-Type: text/html; charset="ISO-8859-1"
607 Content-Transfer-Encoding: quoted-printable
612 cat >`mhpath new` <<'EOF'
614 Content-Type: text/html; charset="ISO-8859-1"
615 Content-Transfer-Encoding: quoted-printable
616 Date: Thu, 11 Apr 2013 02:47:08 -0700
618 From: <sender@example.com>
619 Subject: body requires binary encoding
622 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
623 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
624 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
625 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
626 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
627 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
628 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
629 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
630 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
631 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
632 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
633 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
634 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
635 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
636 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
637 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
638 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
639 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
640 #333333" size=3D"2">$6.00</font></td></tr>
646 if [ $can_reformat_texthtml -eq 1 ]; then
647 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
648 #### Truncate to avoid comparing the html portion because it can
649 #### get reformatted.
650 mhfixmsg last
-outfile - | uniq | head -22 >"$actual"
651 check
"$expected" "$actual" 'ignore space'
653 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
659 # Also checks preservation of attributes after one (charset) that is
661 cat >"$expected" <<EOF
662 To: recipient@example.com
663 From: sender@example.com
664 Subject: mhfixmsg textcodeset test
666 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
668 ------- =_aaaaaaaaaa0
669 Content-Type: text/plain; charset="utf-8"; name="square.txt"
670 Content-Disposition: attachment; filename="square.txt"
671 Content-Transfer-Encoding: 8bit
675 ------- =_aaaaaaaaaa0--
678 #### Generated the encoded text below with:
679 #### $ printf '\xbd\xb2=\xbc\n' | base64
680 cat >`mhpath new` <<EOF
681 To: recipient@example.com
682 From: sender@example.com
683 Subject: mhfixmsg textcodeset test
685 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
687 ------- =_aaaaaaaaaa0
688 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
689 Content-Disposition: attachment; filename="square.txt"
690 Content-Transfer-Encoding: base64
694 ------- =_aaaaaaaaaa0--
698 mhfixmsg last
-textcodeset utf-8
-outfile "$actual" 2>"$actual.err"
699 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
701 echo skipping
-textcodeset check because nmh was built without
iconv
702 rm -f "$expected" "$actual" "$actual.err"
704 check
"$expected" "$actual"
710 # check -nofixboundary
711 cat >"$expected" <<EOF
714 cat >`mhpath new` <<EOF
715 Date: Fri, 13 May 2011 08:21:12 -0500
716 Content-Type: multipart/alternative;
717 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
718 Content-Transfer-Encoding: 8bit
720 From: <sender@example.com>
721 To: <recipient@example.com>
722 Subject: mhfixmsg bad boundary test
724 This is a multi-part message in MIME format.
726 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
727 Content-Type: text/plain
729 The boundaries of this part don't match the header boundary.
731 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
734 cp -p `mhpath last` `mhpath new`
736 run_test
'mhfixmsg last -nofixboundary' ''
737 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
740 # check that message is not output when fed through stdin
741 mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
742 check
"$expected" "$actual"
743 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
744 "$actual.err" >/dev
/null
; then
747 echo "$0: test failed, output is in $actual.err."
748 failed
=`expr ${failed:-0} + 1`
752 # check fixup of erroneous boundary in multipart (-fixboundary,
753 # enabled by default)
755 cat >"$expected" <<EOF
756 Date: Fri, 13 May 2011 08:21:12 -0500
757 Content-Type: multipart/alternative;
758 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
759 Content-Transfer-Encoding: 8bit
761 From: <sender@example.com>
762 To: <recipient@example.com>
763 Subject: mhfixmsg bad boundary test
765 This is a multi-part message in MIME format.
767 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
768 Content-Type: text/plain
770 The boundaries of this part don't match the header boundary.
772 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
775 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
776 "mhfixmsg: 17, fix multipart boundary"
777 check
"$expected" "$actual"
780 # check that text/plain part is added to lone text/html in multipart/related
781 cat >"$expected" <<EOF
783 Date: Tue, 26 Feb 2013 18:07:20 -0600
784 Subject: multipart/related, not /alternative
785 Content-Type: multipart/related;
786 boundary="----=_Part_90310_101292502.1"
788 ------=_Part_90310_101292502.1
789 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
791 ------=_nmh-multipart1
792 Content-Type: text/plain; charset="us-ascii"
793 Content-Transfer-Encoding: 7bit
795 This is the real content.
797 ------=_nmh-multipart1
798 Content-Type: text/html; charset="us-ascii"
799 Content-Transfer-Encoding: 7bit
802 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
803 <title>HTML Content</title>
806 This is the real content.
810 ------=_nmh-multipart1--
812 ------=_Part_90310_101292502.1
813 Content-Type: text/plain; charset="us-ascii"
814 Content-Transfer-Encoding: 7bit
816 Your email client does not support HTML messages
818 ------=_Part_90310_101292502.1--
821 cat >`mhpath new` <<EOF
823 Date: Tue, 26 Feb 2013 18:07:20 -0600
824 Subject: multipart/related, not /alternative
825 Content-Type: multipart/related;
826 boundary="----=_Part_90310_101292502.1"
828 ------=_Part_90310_101292502.1
829 Content-Type: text/html; charset="us-ascii"
830 Content-Transfer-Encoding: 7bit
833 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
834 <title>HTML Content</title>
837 This is the real content.
840 ------=_Part_90310_101292502.1
841 Content-Type: text/plain; charset="us-ascii"
842 Content-Transfer-Encoding: 7bit
844 Your email client does not support HTML messages
845 ------=_Part_90310_101292502.1--
848 if [ $can_reformat_texthtml -eq 1 ]; then
849 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
850 mhfixmsg last
-outfile - | uniq >"$actual"
851 check
"$expected" "$actual"
857 # check handling of rfc822 message type
858 cat >"$expected" <<EOF
859 From: Test <test@example.com>
860 To: Some User <user@example.com>
861 Date: Fri, 29 Sep 2006 00:00:00
862 Message-Id: @test.nmh
863 Subject: message with message/rfc822 attachment
865 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
867 and some garbage before the attachment
869 ------- =_aaaaaaaaaa0
870 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
871 Content-Description: 1552
872 Content-Disposition: attachment; filename="1552"
874 From: Test <test@example.com>
875 To: <another_user@example.com>
876 Date: Thu, 28 Sep 2006 00:00:00
877 Message-Id: @test.nmh
878 Subject: message/rfc822 attachment
880 This is an RFC-822 message.
882 ------- =_aaaaaaaaaa0--
884 and some garbage at the end
887 cat >`mhpath new` <<EOF
888 From: Test <test@example.com>
889 To: Some User <user@example.com>
890 Date: Fri, 29 Sep 2006 00:00:00
891 Message-Id: @test.nmh
892 Subject: message with message/rfc822 attachment
894 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
896 and some garbage before the attachment
898 ------- =_aaaaaaaaaa0
899 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
900 Content-Description: 1552
901 Content-Disposition: attachment; filename="1552"
903 From: Test <test@example.com>
904 To: <another_user@example.com>
905 Date: Thu, 28 Sep 2006 00:00:00
906 Message-Id: @test.nmh
907 Subject: message/rfc822 attachment
909 This is an RFC-822 message.
911 ------- =_aaaaaaaaaa0--
913 and some garbage at the end
916 run_test
'mhfixmsg last -outfile '"$actual" ''
917 check
"$expected" "$actual"
920 # check stripping of CRs from ASCII text context
921 cat >"$expected" <<EOF
923 From: sender@example.com
924 To: recipient@example.com
925 Subject: message with CR's
926 Date: Mon, 29 Apr 2013 11:51:45 -0400
928 There are two CR-LF pairs at the end of this sentence.
932 cat >`mhpath new` <<'EOF'
934 From: sender@example.com
935 To: recipient@example.com
936 Subject: message with CR's
937 Date: Mon, 29 Apr 2013 11:51:45 -0400
939 There are two CR-LF pairs at the end of this sentence.
943 mhfixmsg last
-outfile "$actual"
944 check
"$expected" "$actual"
947 # check -replacetextplain
948 cat >"$expected" <<EOF
949 To: recipient@example.com
950 From: sender@example.com
951 Subject: mhfixmsg replacement of bad text/plain part test
953 Content-Type: multipart/alternative; boundary="----=_Part_876302"
956 Content-Type: text/plain; charset="UTF-8"
957 Content-Transfer-Encoding: 8bit
959 Yes, the text/plain part really was empty.
962 Content-Type: text/html; charset="UTF-8"
963 Content-Transfer-Encoding: 8bit
964 Content-Disposition: inline
967 <title>eticket</title>
970 Yes, the text/plain part really was empty.
974 ------=_Part_876302--
977 cat >`mhpath new` <<'EOF'
978 To: recipient@example.com
979 From: sender@example.com
980 Subject: mhfixmsg replacement of bad text/plain part test
982 Content-Type: multipart/alternative; boundary="----=_Part_876302"
985 Content-Type: text/plain; charset="iso-8859-15"
986 Content-Transfer-Encoding: 7bit
987 Content-Disposition: inline
992 Content-Type: text/html; charset="UTF-8"
993 Content-Transfer-Encoding: 8bit
994 Content-Disposition: inline
997 <title>eticket</title>
1000 Yes, the text/plain part really was empty.
1004 ------=_Part_876302--
1007 mhfixmsg last
-replacetextplain -outfile "$actual"
1008 check
"$expected" "$actual"
1010 # check -noreplacetextplain
1011 cat >"$expected" <<EOF
1012 To: recipient@example.com
1013 From: sender@example.com
1014 Subject: mhfixmsg replacement of bad text/plain part test
1016 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1019 Content-Type: text/plain; charset="iso-8859-15"
1020 Content-Transfer-Encoding: 7bit
1021 Content-Disposition: inline
1026 Content-Type: text/html; charset="UTF-8"
1027 Content-Transfer-Encoding: 8bit
1028 Content-Disposition: inline
1031 <title>eticket</title>
1034 Yes, the text/plain part really was empty.
1038 ------=_Part_876302--
1041 mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1042 check
"$expected" "$actual"
1046 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1049 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1050 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1051 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1053 run_test
'mhfixmsg 15' ''
1054 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1055 "${MH_TEST_DIR}/Mail/inbox/15.original"
1059 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1061 run_test
'mhfixmsg 19 -normmproc'
1062 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1063 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1067 run_test
'mhfixmsg 20 -rmmproc true'
1068 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1069 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1070 failed
=`expr ${failed:-0} + 1`
1074 # make sure there are no tmp files left over
1075 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1077 cat >"$expected" <<EOF
1080 check
"$expected" "$actual"