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 handling of boundary string that appears in message body
254 cat >"$expected" <<EOF
256 From: sender@example.com
257 To: bonquiqui@example.com
259 Date: Sat, 26 Jan 2013 17:37:53 -0500
260 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
262 ------=_nmh-multipart-3
263 Content-Type: text/plain; charset="Windows-1252"
264 Content-Transfer-Encoding: 8bit
266 ------=_nmh-multipart
267 ------=_nmh-multipart-1
268 ------=_nmh-multipart-2
270 ------=_nmh-multipart-3
271 Content-Type: text/html; charset="Windows-1252"
272 Content-Transfer-Encoding: 8bit
276 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
277 <meta name="Generator" content="Microsoft Exchange Server">
278 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
281 ------=_nmh-multipart<br>
282 ------=_nmh-multipart-1<br>
283 ------=_nmh-multipart-2<br>
287 ------=_nmh-multipart-3--
290 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
292 From: sender@example.com
293 To: bonquiqui@example.com
295 Date: Sat, 26 Jan 2013 17:37:53 -0500
296 Content-Type: text/html; charset="Windows-1252"
297 Content-Transfer-Encoding: quoted-printable
301 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
303 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
304 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
305 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
308 ------=3D_nmh-multipart<br>
309 ------=3D_nmh-multipart-1<br>
310 ------=3D_nmh-multipart-2<br>
315 if [ $can_reformat_texthtml -eq 1 ]; then
316 printf '%s\n' "mhfixmsg: 12, insert text/plain part
317 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
320 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
321 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
322 check
"$expected" "$actual"
323 check
"$expected.err" "$actual.err"
330 cat >"$expected" <<EOF
332 From: sender@example.com
333 To: bonquiqui@example.com
335 Date: Sat, 26 Jan 2013 17:37:53 -0500
336 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
338 ------=_nmh-multipart
339 Content-Type: text/plain; charset="Windows-1252"
340 Content-Transfer-Encoding: 8bit
342 Need to go! Need ... to ... go!
344 ------=_nmh-multipart
345 Content-Type: text/html; charset="Windows-1252"
346 Content-Transfer-Encoding: quoted-printable
350 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
352 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
353 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
354 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
358 <div>Need to go! Need ... to ... go!</div>
362 ------=_nmh-multipart--
365 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
367 From: sender@example.com
368 To: bonquiqui@example.com
370 Date: Sat, 26 Jan 2013 17:37:53 -0500
371 Content-Type: text/html; charset="Windows-1252"
372 Content-Transfer-Encoding: quoted-printable
376 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
378 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
379 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
380 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
384 <div>Need to go! Need ... to ... go!</div>
389 if [ $can_reformat_texthtml -eq 1 ]; then
390 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
392 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
393 mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | uniq >"$actual"
394 check
"$expected" "$actual"
395 check
"$expected.err" "$actual.err"
401 # check -decode (enabled by default)
402 cat >"$expected" <<EOF
403 To: recipient@example.com
404 From: sender@example.com
405 Subject: mhfixmsg decode test
407 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
409 ------- =_aaaaaaaaaa0
410 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
411 Content-Disposition: attachment; filename="test4.txt"
412 Content-Transfer-Encoding: 8bit
414 This is a text/plain part.
416 ------- =_aaaaaaaaaa0--
419 cat >`mhpath new` <<EOF
420 To: recipient@example.com
421 From: sender@example.com
422 Subject: mhfixmsg decode test
424 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
426 ------- =_aaaaaaaaaa0
427 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
428 Content-Disposition: attachment; filename="test4.txt"
429 Content-Transfer-Encoding: base64
431 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
433 ------- =_aaaaaaaaaa0--
436 mhfixmsg last
-outfile "$actual"
437 check
"$expected" "$actual"
440 # check -decode with more complicated content structure
442 To: recipient@example.com
443 From: sender@example.com
444 Subject: mhfixmsg decode test 2
446 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
448 This is additional content before the first subpart of the multipart.
450 ------- =_aaaaaaaaaa0
451 Content-Type: multipart/related;
452 type="multipart/alternative";
453 boundary="subpart__1.1"
456 Content-Type: text/plain; charset="iso-8859-1"
457 Content-Disposition: attachment; filename="test1.txt"
459 This is the first text/plain part, in a subpart.
463 This is additional content after the last subpart of the multipart.
465 ------- =_aaaaaaaaaa0
466 Content-Type: text/plain; charset="iso-8859-1"
467 Content-Disposition: attachment; filename="test2.txt"
468 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
469 Content-Transfer-Encoding: 8bit
471 This is the second text/plain part.
473 ------- =_aaaaaaaaaa0
474 Content-Type: text/plain; charset="iso-8859-1"
475 Content-Disposition: attachment; filename="test3.txt"
477 This is the third text/plain part.
479 ------- =_aaaaaaaaaa0
480 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
481 Content-Disposition: attachment; filename="test4.txt"
482 Content-Transfer-Encoding: 8bit
484 This is the fourth text/plain part.
486 ------- =_aaaaaaaaaa0--
488 This is additional content after the last subpart of the multipart.
491 cat >`mhpath new` <<EOF
492 To: recipient@example.com
493 From: sender@example.com
494 Subject: mhfixmsg decode test 2
496 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
498 This is additional content before the first subpart of the multipart.
500 ------- =_aaaaaaaaaa0
501 Content-Type: multipart/related;
502 type="multipart/alternative";
503 boundary="subpart__1.1"
506 Content-Type: text/plain; charset="iso-8859-1"
507 Content-Disposition: attachment; filename="test1.txt"
509 This is the first text/plain part, in a subpart.
513 This is additional content after the last subpart of the multipart.
515 ------- =_aaaaaaaaaa0
516 Content-Type: text/plain; charset="iso-8859-1"
517 Content-Disposition: attachment; filename="test2.txt"
518 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
519 Content-Transfer-Encoding: quoted-printable
521 This is the second text/plain part.
523 ------- =_aaaaaaaaaa0
524 Content-Type: text/plain; charset="iso-8859-1"
525 Content-Disposition: attachment; filename="test3.txt"
527 This is the third text/plain part.
529 ------- =_aaaaaaaaaa0
530 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
531 Content-Disposition: attachment; filename="test4.txt"
532 Content-Transfer-Encoding: base64
534 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
536 ------- =_aaaaaaaaaa0--
538 This is additional content after the last subpart of the multipart.
540 mhfixmsg last
-outfile "$actual"
541 check
"$expected" "$actual"
544 # check attempted -decode of binary text
545 #### Generated the encoded text below with:
546 #### $ printf '\x0d\xbd\xb2=\xbc\n' | base64
547 cat >`mhpath new` <<EOF
548 To: recipient@example.com
549 From: sender@example.com
550 Subject: mhfixmsg attempted binary decode test
552 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
554 ------- =_aaaaaaaaaa0
555 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
556 Content-Transfer-Encoding: base64
560 ------- =_aaaaaaaaaa0--
563 cp -p `mhpath last` "$expected"
567 check
`mhpath last` "$expected" 'keep first'
570 # check -decode of binary text
571 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
572 From: sender@example.com
573 Subject: mhfixmsg binary decode test
575 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
577 ------- =_aaaaaaaaaa0
578 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"square.txt\"
579 Content-Transfer-Encoding: binary
583 ------- =_aaaaaaaaaa0--
585 ## output_content() in mhoutsbr.c can't handle binary content.
586 ## mhfixmsg last -decodetext binary -outfile "$actual"
587 ## check "$expected" "$actual"
592 # check that -reformat succeeds when decode of binary text fails
593 cat >"$expected" <<'EOF'
595 Date: Thu, 11 Apr 2013 02:47:08 -0700
597 From: <sender@example.com>
598 Subject: body requires binary encoding
599 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
601 ------=_nmh-multipart
602 Content-Type: text/plain; charset="ISO-8859-1"
603 Content-Transfer-Encoding: 8bit
608 Vehicle License Fee $1.84
611 ------=_nmh-multipart
612 Content-Type: text/html; charset="ISO-8859-1"
613 Content-Transfer-Encoding: quoted-printable
618 cat >`mhpath new` <<'EOF'
620 Content-Type: text/html; charset="ISO-8859-1"
621 Content-Transfer-Encoding: quoted-printable
622 Date: Thu, 11 Apr 2013 02:47:08 -0700
624 From: <sender@example.com>
625 Subject: body requires binary encoding
628 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
629 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
630 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
631 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
632 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
633 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
634 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
635 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
636 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
637 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
638 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
639 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
640 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
641 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
642 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
643 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
644 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
645 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
646 #333333" size=3D"2">$6.00</font></td></tr>
652 if [ $can_reformat_texthtml -eq 1 ]; then
653 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
654 #### Truncate to avoid comparing the html portion because it can
655 #### get reformatted.
656 mhfixmsg last
-outfile - | uniq | head -22 >"$actual"
657 check
"$expected" "$actual" 'ignore space'
659 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
665 # Also checks preservation of attributes after one (charset) that is
667 cat >"$expected" <<EOF
668 To: recipient@example.com
669 From: sender@example.com
670 Subject: mhfixmsg textcodeset test
672 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
674 ------- =_aaaaaaaaaa0
675 Content-Type: text/plain; charset="utf-8"; name="square.txt"
676 Content-Disposition: attachment; filename="square.txt"
677 Content-Transfer-Encoding: 8bit
681 ------- =_aaaaaaaaaa0--
684 #### Generated the encoded text below with:
685 #### $ printf '\xbd\xb2=\xbc\n' | base64
686 cat >`mhpath new` <<EOF
687 To: recipient@example.com
688 From: sender@example.com
689 Subject: mhfixmsg textcodeset test
691 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
693 ------- =_aaaaaaaaaa0
694 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
695 Content-Disposition: attachment; filename="square.txt"
696 Content-Transfer-Encoding: base64
700 ------- =_aaaaaaaaaa0--
704 mhfixmsg last
-textcodeset utf
-8 -outfile "$actual" 2>"$actual.err"
705 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
707 echo "$0: skipping -textcodeset check because nmh was built without iconv"
708 rm -f "$expected" "$actual" "$actual.err"
710 check
"$expected" "$actual"
716 # check -nofixboundary
717 cat >"$expected" <<EOF
720 cat >`mhpath new` <<EOF
721 Date: Fri, 13 May 2011 08:21:12 -0500
722 Content-Type: multipart/alternative;
723 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
724 Content-Transfer-Encoding: 8bit
726 From: <sender@example.com>
727 To: <recipient@example.com>
728 Subject: mhfixmsg bad boundary test
730 This is a multi-part message in MIME format.
732 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
733 Content-Type: text/plain
735 The boundaries of this part don't match the header boundary.
737 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
740 cp -p `mhpath last` `mhpath new`
742 run_test
'mhfixmsg last -nofixboundary' ''
743 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
746 # check that message is not output when fed through stdin
747 mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
748 check
"$expected" "$actual"
749 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
750 "$actual.err" >/dev
/null
; then
753 echo "$0: test failed, output is in $actual.err."
754 failed
=`expr ${failed:-0} + 1`
758 # check fixup of erroneous boundary in multipart (-fixboundary,
759 # enabled by default)
761 cat >"$expected" <<EOF
762 Date: Fri, 13 May 2011 08:21:12 -0500
763 Content-Type: multipart/alternative;
764 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
765 Content-Transfer-Encoding: 8bit
767 From: <sender@example.com>
768 To: <recipient@example.com>
769 Subject: mhfixmsg bad boundary test
771 This is a multi-part message in MIME format.
773 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
774 Content-Type: text/plain
776 The boundaries of this part don't match the header boundary.
778 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
781 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
782 "mhfixmsg: 17, fix multipart boundary"
783 check
"$expected" "$actual"
786 # check that text/plain part is added to lone text/html in multipart/related
787 cat >"$expected" <<EOF
789 Date: Tue, 26 Feb 2013 18:07:20 -0600
790 Subject: multipart/related, not /alternative
791 Content-Type: multipart/related;
792 boundary="----=_Part_90310_101292502.1"
794 ------=_Part_90310_101292502.1
795 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
797 ------=_nmh-multipart1
798 Content-Type: text/plain; charset="us-ascii"
799 Content-Transfer-Encoding: 7bit
801 This is the real content.
803 ------=_nmh-multipart1
804 Content-Type: text/html; charset="us-ascii"
805 Content-Transfer-Encoding: 7bit
808 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
809 <title>HTML Content</title>
812 This is the real content.
816 ------=_nmh-multipart1--
818 ------=_Part_90310_101292502.1
819 Content-Type: text/plain; charset="us-ascii"
820 Content-Transfer-Encoding: 7bit
822 Your email client does not support HTML messages
824 ------=_Part_90310_101292502.1--
827 cat >`mhpath new` <<EOF
829 Date: Tue, 26 Feb 2013 18:07:20 -0600
830 Subject: multipart/related, not /alternative
831 Content-Type: multipart/related;
832 boundary="----=_Part_90310_101292502.1"
834 ------=_Part_90310_101292502.1
835 Content-Type: text/html; charset="us-ascii"
836 Content-Transfer-Encoding: 7bit
839 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
840 <title>HTML Content</title>
843 This is the real content.
846 ------=_Part_90310_101292502.1
847 Content-Type: text/plain; charset="us-ascii"
848 Content-Transfer-Encoding: 7bit
850 Your email client does not support HTML messages
851 ------=_Part_90310_101292502.1--
854 if [ $can_reformat_texthtml -eq 1 ]; then
855 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
856 mhfixmsg last
-outfile - | uniq >"$actual"
857 check
"$expected" "$actual"
863 # check handling of rfc822 message type
864 cat >"$expected" <<EOF
865 From: Test <test@example.com>
866 To: Some User <user@example.com>
867 Date: Fri, 29 Sep 2006 00:00:00
868 Message-Id: @test.nmh
869 Subject: message with message/rfc822 attachment
871 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
873 and some garbage before the attachment
875 ------- =_aaaaaaaaaa0
876 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
877 Content-Description: 1552
878 Content-Disposition: attachment; filename="1552"
880 From: Test <test@example.com>
881 To: <another_user@example.com>
882 Date: Thu, 28 Sep 2006 00:00:00
883 Message-Id: @test.nmh
884 Subject: message/rfc822 attachment
886 This is an RFC-822 message.
888 ------- =_aaaaaaaaaa0--
890 and some garbage at the end
893 cat >`mhpath new` <<EOF
894 From: Test <test@example.com>
895 To: Some User <user@example.com>
896 Date: Fri, 29 Sep 2006 00:00:00
897 Message-Id: @test.nmh
898 Subject: message with message/rfc822 attachment
900 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
902 and some garbage before the attachment
904 ------- =_aaaaaaaaaa0
905 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
906 Content-Description: 1552
907 Content-Disposition: attachment; filename="1552"
909 From: Test <test@example.com>
910 To: <another_user@example.com>
911 Date: Thu, 28 Sep 2006 00:00:00
912 Message-Id: @test.nmh
913 Subject: message/rfc822 attachment
915 This is an RFC-822 message.
917 ------- =_aaaaaaaaaa0--
919 and some garbage at the end
922 run_test
'mhfixmsg last -outfile '"$actual" ''
923 check
"$expected" "$actual"
926 # check stripping of CRs from ASCII text context
927 cat >"$expected" <<EOF
929 From: sender@example.com
930 To: recipient@example.com
931 Subject: message with CR's
932 Date: Mon, 29 Apr 2013 11:51:45 -0400
934 There are two CR-LF pairs at the end of this sentence.
938 cat >`mhpath new` <<'EOF'
940 From: sender@example.com
941 To: recipient@example.com
942 Subject: message with CR's
943 Date: Mon, 29 Apr 2013 11:51:45 -0400
945 There are two CR-LF pairs at the end of this sentence.
949 mhfixmsg last
-outfile "$actual"
950 check
"$expected" "$actual"
953 # check -replacetextplain
954 cat >"$expected" <<EOF
955 To: recipient@example.com
956 From: sender@example.com
957 Subject: mhfixmsg replacement of bad text/plain part test
959 Content-Type: multipart/alternative; boundary="----=_Part_876302"
962 Content-Type: text/plain; charset="UTF-8"
963 Content-Transfer-Encoding: 8bit
965 Yes, the text/plain part really was empty.
968 Content-Type: text/html; charset="UTF-8"
969 Content-Transfer-Encoding: 8bit
970 Content-Disposition: inline
973 <title>eticket</title>
976 Yes, the text/plain part really was empty.
980 ------=_Part_876302--
983 cat >`mhpath new` <<'EOF'
984 To: recipient@example.com
985 From: sender@example.com
986 Subject: mhfixmsg replacement of bad text/plain part test
988 Content-Type: multipart/alternative; boundary="----=_Part_876302"
991 Content-Type: text/plain; charset="iso-8859-15"
992 Content-Transfer-Encoding: 7bit
993 Content-Disposition: inline
998 Content-Type: text/html; charset="UTF-8"
999 Content-Transfer-Encoding: 8bit
1000 Content-Disposition: inline
1003 <title>eticket</title>
1006 Yes, the text/plain part really was empty.
1010 ------=_Part_876302--
1013 if [ $can_reformat_texthtml -eq 1 ]; then
1014 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
1015 mhfixmsg last
-replacetextplain -outfile - | uniq > "$actual"
1016 check
"$expected" "$actual"
1022 # check -noreplacetextplain
1023 cat >"$expected" <<EOF
1024 To: recipient@example.com
1025 From: sender@example.com
1026 Subject: mhfixmsg replacement of bad text/plain part test
1028 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1031 Content-Type: text/plain; charset="iso-8859-15"
1032 Content-Transfer-Encoding: 7bit
1033 Content-Disposition: inline
1038 Content-Type: text/html; charset="UTF-8"
1039 Content-Transfer-Encoding: 8bit
1040 Content-Disposition: inline
1043 <title>eticket</title>
1046 Yes, the text/plain part really was empty.
1050 ------=_Part_876302--
1053 mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1054 check
"$expected" "$actual"
1058 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1061 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1062 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1063 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1065 run_test
'mhfixmsg 15' ''
1066 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1067 "${MH_TEST_DIR}/Mail/inbox/15.original"
1071 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1073 run_test
'mhfixmsg 19 -normmproc'
1074 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1075 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1079 run_test
'mhfixmsg 20 -rmmproc true'
1080 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1081 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1082 failed
=`expr ${failed:-0} + 1`
1086 # make sure there are no tmp files left over
1087 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1089 cat >"$expected" <<EOF
1092 check
"$expected" "$actual"