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"
17 #### w3m needs $HOME to be writeable.
18 if [ -w "$HOME" ]; then
21 #### $HOME isn't writeable, so use a directory that should be.
26 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
27 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
28 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
29 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
32 if grep mhfixmsg-format
-text
/html
"${MH_TEST_DIR}/Mail/mhn.defaults" \
34 can_reformat_texthtml
=1
36 echo "$0: skipping -reformat check because \
37 mhfixmsg-format-text/html is not available"
38 can_reformat_texthtml
=0
44 # Verified behavior consistent with compiled sendmail.
45 cat >"$expected" <<EOF
46 Usage: mhfixmsg [+folder] [msgs] [switches]
64 mhfixmsg
-help >"$actual" 2>&1
65 check
"$expected" "$actual"
69 # Verified same behavior as compiled mhfixmsg.
70 case `mhfixmsg -version` in
72 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
73 failed
=`expr ${failed:-0} + 1`;;
77 # check that non-MIME messages aren't modified
79 run_test
'mhfixmsg first -outfile '"$actual" ''
80 check
"`mhpath first`" "$actual" 'keep first'
83 # check that non-MIME messages with no bodies aren't modified
85 cat >`mhpath new` <<EOF
86 From: Test <test@example.com>
87 To: Some User <user@example.com>
88 Date: Fri, 29 Sep 2006 00:00:00
90 Subject: message with no body
93 run_test
'mhfixmsg last -outfile '"$actual" ''
94 check
"`mhpath last`" "$actual"
98 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
101 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
102 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
104 Content-Type: MULTIPART/MIXED;
105 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
106 Content-Transfer-Encoding: QUOTED-PRINTABLE
108 This message is in MIME format. The first part should be readable
110 while the remaining parts are likely unreadable without MIME-aware
113 ------=_NextPart_000_0000_00000000.00000000
114 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
115 Content-Transfer-Encoding: 8BIT
117 Some text in swedish.
119 Varf=C3=B6r inte anv=C3=A4nda...
121 ------=_NextPart_000_0000_00000000.00000000--
123 And some text after the last part.
126 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
128 run_test
'mhfixmsg last -nofixcte' ''
129 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
132 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
134 cat >"$expected" <<EOF
137 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
138 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
140 Content-Type: MULTIPART/MIXED;
141 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
142 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
143 Content-Transfer-Encoding: 8bit
145 This message is in MIME format. The first part should be readable
147 while the remaining parts are likely unreadable without MIME-aware
150 ------=_NextPart_000_0000_00000000.00000000
151 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
152 Content-Transfer-Encoding: 8BIT
154 Some text in swedish.
156 Varf=C3=B6r inte anv=C3=A4nda...
158 ------=_NextPart_000_0000_00000000.00000000--
160 And some text after the last part.
163 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
164 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
165 QUOTED-PRINTABLE with 8 bit"
166 check
"$expected" "$actual" 'keep first'
169 # check with no options: checks backup
170 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
171 folder last
>/dev
/null
172 run_test
'mhfixmsg' ''
173 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
174 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
175 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
178 # check backup with -file
179 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
180 folder last
>/dev
/null
181 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
182 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
183 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
186 # check -reformat (enabled by default): addition of text/plain part
187 # to solitary text/html part
189 cat >"$expected" <<EOF
191 From: sender@example.com
192 To: bonquiqui@example.com
194 Date: Sat, 26 Jan 2013 17:37:53 -0500
195 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
197 ------=_nmh-multipart
198 Content-Type: text/plain; charset="Windows-1252"
199 Content-Transfer-Encoding: 8bit
201 Need to go! Need ... to ... go!
203 ------=_nmh-multipart
204 Content-Type: text/html; charset="Windows-1252"
205 Content-Transfer-Encoding: 8bit
209 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
210 <meta name="Generator" content="Microsoft Exchange Server">
211 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
215 <div>Need to go! Need ... to ... go!</div>
219 ------=_nmh-multipart--
222 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
224 From: sender@example.com
225 To: bonquiqui@example.com
227 Date: Sat, 26 Jan 2013 17:37:53 -0500
228 Content-Type: text/html; charset="Windows-1252"
229 Content-Transfer-Encoding: quoted-printable
233 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
235 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
236 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
237 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
241 <div>Need to go! Need ... to ... go!</div>
246 if [ $can_reformat_texthtml -eq 1 ]; then
247 printf '%s\n' "mhfixmsg: 12, insert text/plain part
248 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
251 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
252 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
253 check
"$expected" "$actual"
254 check
"$expected.err" "$actual.err"
260 # check implicit -file with absolute pathname
261 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
264 # check handling of boundary string that appears in message body
266 cat >"$expected" <<EOF
268 From: sender@example.com
269 To: bonquiqui@example.com
271 Date: Sat, 26 Jan 2013 17:37:53 -0500
272 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
274 ------=_nmh-multipart-3
275 Content-Type: text/plain; charset="Windows-1252"
276 Content-Transfer-Encoding: 8bit
278 ------=_nmh-multipart
279 ------=_nmh-multipart-1
280 ------=_nmh-multipart-2
282 ------=_nmh-multipart-3
283 Content-Type: text/html; charset="Windows-1252"
284 Content-Transfer-Encoding: 8bit
288 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
289 <meta name="Generator" content="Microsoft Exchange Server">
290 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
293 ------=_nmh-multipart<br>
294 ------=_nmh-multipart-1<br>
295 ------=_nmh-multipart-2<br>
299 ------=_nmh-multipart-3--
302 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
304 From: sender@example.com
305 To: bonquiqui@example.com
307 Date: Sat, 26 Jan 2013 17:37:53 -0500
308 Content-Type: text/html; charset="Windows-1252"
309 Content-Transfer-Encoding: quoted-printable
313 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
315 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
316 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
317 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
320 ------=3D_nmh-multipart<br>
321 ------=3D_nmh-multipart-1<br>
322 ------=3D_nmh-multipart-2<br>
327 if [ $can_reformat_texthtml -eq 1 ]; then
328 printf '%s\n' "mhfixmsg: 12, insert text/plain part
329 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
332 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
333 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
334 check
"$expected" "$actual"
335 check
"$expected.err" "$actual.err"
342 cat >"$expected" <<EOF
344 From: sender@example.com
345 To: bonquiqui@example.com
347 Date: Sat, 26 Jan 2013 17:37:53 -0500
348 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
350 ------=_nmh-multipart
351 Content-Type: text/plain; charset="Windows-1252"
352 Content-Transfer-Encoding: 8bit
354 Need to go! Need ... to ... go!
356 ------=_nmh-multipart
357 Content-Type: text/html; charset="Windows-1252"
358 Content-Transfer-Encoding: quoted-printable
362 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
364 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
365 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
366 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
370 <div>Need to go! Need ... to ... go!</div>
374 ------=_nmh-multipart--
377 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
379 From: sender@example.com
380 To: bonquiqui@example.com
382 Date: Sat, 26 Jan 2013 17:37:53 -0500
383 Content-Type: text/html; charset="Windows-1252"
384 Content-Transfer-Encoding: quoted-printable
388 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
390 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
391 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
392 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
396 <div>Need to go! Need ... to ... go!</div>
401 if [ $can_reformat_texthtml -eq 1 ]; then
402 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
404 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
405 mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | uniq >"$actual"
406 check
"$expected" "$actual"
407 check
"$expected.err" "$actual.err"
413 # check -decode (enabled by default)
414 cat >"$expected" <<EOF
415 To: recipient@example.com
416 From: sender@example.com
417 Subject: mhfixmsg decode test
419 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
421 ------- =_aaaaaaaaaa0
422 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
423 Content-Disposition: attachment; filename="test4.txt"
424 Content-Transfer-Encoding: 8bit
426 This is a text/plain part.
428 ------- =_aaaaaaaaaa0--
431 cat >`mhpath new` <<EOF
432 To: recipient@example.com
433 From: sender@example.com
434 Subject: mhfixmsg decode test
436 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
438 ------- =_aaaaaaaaaa0
439 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
440 Content-Disposition: attachment; filename="test4.txt"
441 Content-Transfer-Encoding: base64
443 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
445 ------- =_aaaaaaaaaa0--
448 mhfixmsg last
-outfile "$actual"
449 check
"$expected" "$actual"
452 # check -decode with more complicated content structure
454 To: recipient@example.com
455 From: sender@example.com
456 Subject: mhfixmsg decode test 2
458 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
460 This is additional content before the first subpart of the multipart.
462 ------- =_aaaaaaaaaa0
463 Content-Type: multipart/related;
464 type="multipart/alternative";
465 boundary="subpart__1.1"
468 Content-Type: text/plain; charset="iso-8859-1"
469 Content-Disposition: attachment; filename="test1.txt"
471 This is the first text/plain part, in a subpart.
475 This is additional content after the last subpart of the multipart.
477 ------- =_aaaaaaaaaa0
478 Content-Type: text/plain; charset="iso-8859-1"
479 Content-Disposition: attachment; filename="test2.txt"
480 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
481 Content-Transfer-Encoding: 8bit
483 This is the second text/plain part.
485 ------- =_aaaaaaaaaa0
486 Content-Type: text/plain; charset="iso-8859-1"
487 Content-Disposition: attachment; filename="test3.txt"
489 This is the third text/plain part.
491 ------- =_aaaaaaaaaa0
492 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
493 Content-Disposition: attachment; filename="test4.txt"
494 Content-Transfer-Encoding: 8bit
496 This is the fourth text/plain part.
498 ------- =_aaaaaaaaaa0--
500 This is additional content after the last subpart of the multipart.
503 cat >`mhpath new` <<EOF
504 To: recipient@example.com
505 From: sender@example.com
506 Subject: mhfixmsg decode test 2
508 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
510 This is additional content before the first subpart of the multipart.
512 ------- =_aaaaaaaaaa0
513 Content-Type: multipart/related;
514 type="multipart/alternative";
515 boundary="subpart__1.1"
518 Content-Type: text/plain; charset="iso-8859-1"
519 Content-Disposition: attachment; filename="test1.txt"
521 This is the first text/plain part, in a subpart.
525 This is additional content after the last subpart of the multipart.
527 ------- =_aaaaaaaaaa0
528 Content-Type: text/plain; charset="iso-8859-1"
529 Content-Disposition: attachment; filename="test2.txt"
530 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
531 Content-Transfer-Encoding: quoted-printable
533 This is the second text/plain part.
535 ------- =_aaaaaaaaaa0
536 Content-Type: text/plain; charset="iso-8859-1"
537 Content-Disposition: attachment; filename="test3.txt"
539 This is the third text/plain part.
541 ------- =_aaaaaaaaaa0
542 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
543 Content-Disposition: attachment; filename="test4.txt"
544 Content-Transfer-Encoding: base64
546 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
548 ------- =_aaaaaaaaaa0--
550 This is additional content after the last subpart of the multipart.
552 mhfixmsg last
-outfile "$actual"
553 check
"$expected" "$actual"
556 # check attempted -decode of binary text
557 #### Generated the encoded text below with:
558 #### $ printf '\x0d\xbd\xb2=\xbc\n' | base64
559 cat >`mhpath new` <<EOF
560 To: recipient@example.com
561 From: sender@example.com
562 Subject: mhfixmsg attempted binary decode test
564 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
566 ------- =_aaaaaaaaaa0
567 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
568 Content-Transfer-Encoding: base64
572 ------- =_aaaaaaaaaa0--
575 cp -p `mhpath last` "$expected"
579 check
`mhpath last` "$expected" 'keep first'
582 # check -decode of binary text
583 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
584 From: sender@example.com
585 Subject: mhfixmsg binary decode test
587 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
589 ------- =_aaaaaaaaaa0
590 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"square.txt\"
591 Content-Transfer-Encoding: binary
595 ------- =_aaaaaaaaaa0--
597 ## output_content() in mhoutsbr.c can't handle binary content.
598 ## mhfixmsg last -decodetext binary -outfile "$actual"
599 ## check "$expected" "$actual"
604 # check that -reformat succeeds when decode of binary text fails
605 cat >"$expected" <<'EOF'
607 Date: Thu, 11 Apr 2013 02:47:08 -0700
609 From: <sender@example.com>
610 Subject: body requires binary encoding
611 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
613 ------=_nmh-multipart
614 Content-Type: text/plain; charset="ISO-8859-1"
615 Content-Transfer-Encoding: 8bit
620 Vehicle License Fee $1.84
623 ------=_nmh-multipart
624 Content-Type: text/html; charset="ISO-8859-1"
625 Content-Transfer-Encoding: quoted-printable
630 cat >`mhpath new` <<'EOF'
632 Content-Type: text/html; charset="ISO-8859-1"
633 Content-Transfer-Encoding: quoted-printable
634 Date: Thu, 11 Apr 2013 02:47:08 -0700
636 From: <sender@example.com>
637 Subject: body requires binary encoding
640 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
641 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
642 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
643 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
644 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
645 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
646 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
647 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
648 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
649 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
650 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
651 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
652 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
653 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
654 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
655 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
656 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
657 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
658 #333333" size=3D"2">$6.00</font></td></tr>
664 if [ $can_reformat_texthtml -eq 1 ]; then
665 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
666 #### Truncate to avoid comparing the html portion because it can
667 #### get reformatted.
668 mhfixmsg last
-outfile - | uniq | head -22 >"$actual"
669 check
"$expected" "$actual" 'ignore space'
671 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
677 # Also checks preservation of attributes after one (charset) that is
679 cat >"$expected" <<EOF
680 To: recipient@example.com
681 From: sender@example.com
682 Subject: mhfixmsg textcodeset test
684 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
686 ------- =_aaaaaaaaaa0
687 Content-Type: text/plain; charset="utf-8"; name="square.txt"
688 Content-Disposition: attachment; filename="square.txt"
689 Content-Transfer-Encoding: 8bit
693 ------- =_aaaaaaaaaa0--
696 #### Generated the encoded text below with:
697 #### $ printf '\xbd\xb2=\xbc\n' | base64
698 cat >`mhpath new` <<EOF
699 To: recipient@example.com
700 From: sender@example.com
701 Subject: mhfixmsg textcodeset test
703 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
705 ------- =_aaaaaaaaaa0
706 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
707 Content-Disposition: attachment; filename="square.txt"
708 Content-Transfer-Encoding: base64
712 ------- =_aaaaaaaaaa0--
716 mhfixmsg last
-textcodeset utf-8
-outfile "$actual" 2>"$actual.err"
717 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
719 echo "$0: skipping -textcodeset check because nmh was built without iconv"
720 rm -f "$expected" "$actual" "$actual.err"
722 check
"$expected" "$actual"
728 # check -nofixboundary
729 cat >"$expected" <<EOF
732 cat >`mhpath new` <<EOF
733 Date: Fri, 13 May 2011 08:21:12 -0500
734 Content-Type: multipart/alternative;
735 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
736 Content-Transfer-Encoding: 8bit
738 From: <sender@example.com>
739 To: <recipient@example.com>
740 Subject: mhfixmsg bad boundary test
742 This is a multi-part message in MIME format.
744 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
745 Content-Type: text/plain
747 The boundaries of this part don't match the header boundary.
749 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
752 cp -p `mhpath last` `mhpath new`
754 run_test
'mhfixmsg last -nofixboundary' ''
755 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
758 # check that message is not output when fed through stdin
759 mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
760 check
"$expected" "$actual"
761 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
762 "$actual.err" >/dev
/null
; then
765 echo "$0: test failed, output is in $actual.err."
766 failed
=`expr ${failed:-0} + 1`
770 # check fixup of erroneous boundary in multipart (-fixboundary,
771 # enabled by default)
773 cat >"$expected" <<EOF
774 Date: Fri, 13 May 2011 08:21:12 -0500
775 Content-Type: multipart/alternative;
776 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
777 Content-Transfer-Encoding: 8bit
779 From: <sender@example.com>
780 To: <recipient@example.com>
781 Subject: mhfixmsg bad boundary test
783 This is a multi-part message in MIME format.
785 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
786 Content-Type: text/plain
788 The boundaries of this part don't match the header boundary.
790 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
793 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
794 "mhfixmsg: 17, fix multipart boundary"
795 check
"$expected" "$actual"
798 # check that text/plain part is added to lone text/html in multipart/related
799 cat >"$expected" <<EOF
801 Date: Tue, 26 Feb 2013 18:07:20 -0600
802 Subject: multipart/related, not /alternative
803 Content-Type: multipart/related;
804 boundary="----=_Part_90310_101292502.1"
806 ------=_Part_90310_101292502.1
807 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
809 ------=_nmh-multipart1
810 Content-Type: text/plain; charset="us-ascii"
811 Content-Transfer-Encoding: 7bit
813 This is the real content.
815 ------=_nmh-multipart1
816 Content-Type: text/html; charset="us-ascii"
817 Content-Transfer-Encoding: 7bit
820 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
821 <title>HTML Content</title>
824 This is the real content.
828 ------=_nmh-multipart1--
830 ------=_Part_90310_101292502.1
831 Content-Type: text/plain; charset="us-ascii"
832 Content-Transfer-Encoding: 7bit
834 Your email client does not support HTML messages
836 ------=_Part_90310_101292502.1--
839 cat >`mhpath new` <<EOF
841 Date: Tue, 26 Feb 2013 18:07:20 -0600
842 Subject: multipart/related, not /alternative
843 Content-Type: multipart/related;
844 boundary="----=_Part_90310_101292502.1"
846 ------=_Part_90310_101292502.1
847 Content-Type: text/html; charset="us-ascii"
848 Content-Transfer-Encoding: 7bit
851 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
852 <title>HTML Content</title>
855 This is the real content.
858 ------=_Part_90310_101292502.1
859 Content-Type: text/plain; charset="us-ascii"
860 Content-Transfer-Encoding: 7bit
862 Your email client does not support HTML messages
863 ------=_Part_90310_101292502.1--
866 if [ $can_reformat_texthtml -eq 1 ]; then
867 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
868 mhfixmsg last
-outfile - | uniq >"$actual"
869 check
"$expected" "$actual"
875 # check handling of rfc822 message type
876 cat >"$expected" <<EOF
877 From: Test <test@example.com>
878 To: Some User <user@example.com>
879 Date: Fri, 29 Sep 2006 00:00:00
880 Message-Id: @test.nmh
881 Subject: message with message/rfc822 attachment
883 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
885 and some garbage before the attachment
887 ------- =_aaaaaaaaaa0
888 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
889 Content-Description: 1552
890 Content-Disposition: attachment; filename="1552"
892 From: Test <test@example.com>
893 To: <another_user@example.com>
894 Date: Thu, 28 Sep 2006 00:00:00
895 Message-Id: @test.nmh
896 Subject: message/rfc822 attachment
898 This is an RFC-822 message.
900 ------- =_aaaaaaaaaa0--
902 and some garbage at the end
905 cat >`mhpath new` <<EOF
906 From: Test <test@example.com>
907 To: Some User <user@example.com>
908 Date: Fri, 29 Sep 2006 00:00:00
909 Message-Id: @test.nmh
910 Subject: message with message/rfc822 attachment
912 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
914 and some garbage before the attachment
916 ------- =_aaaaaaaaaa0
917 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
918 Content-Description: 1552
919 Content-Disposition: attachment; filename="1552"
921 From: Test <test@example.com>
922 To: <another_user@example.com>
923 Date: Thu, 28 Sep 2006 00:00:00
924 Message-Id: @test.nmh
925 Subject: message/rfc822 attachment
927 This is an RFC-822 message.
929 ------- =_aaaaaaaaaa0--
931 and some garbage at the end
934 run_test
'mhfixmsg last -outfile '"$actual" ''
935 check
"$expected" "$actual"
938 # check stripping of CRs from ASCII text context
939 cat >"$expected" <<EOF
941 From: sender@example.com
942 To: recipient@example.com
943 Subject: message with CR's
944 Date: Mon, 29 Apr 2013 11:51:45 -0400
946 There are two CR-LF pairs at the end of this sentence.
950 cat >`mhpath new` <<'EOF'
952 From: sender@example.com
953 To: recipient@example.com
954 Subject: message with CR's
955 Date: Mon, 29 Apr 2013 11:51:45 -0400
957 There are two CR-LF pairs at the end of this sentence.
961 mhfixmsg last
-outfile "$actual"
962 check
"$expected" "$actual"
965 # check -replacetextplain
966 cat >"$expected" <<EOF
967 To: recipient@example.com
968 From: sender@example.com
969 Subject: mhfixmsg replacement of bad text/plain part test
971 Content-Type: multipart/alternative; boundary="----=_Part_876302"
974 Content-Type: text/plain; charset="UTF-8"
975 Content-Transfer-Encoding: 8bit
977 Yes, the text/plain part really was empty.
980 Content-Type: text/html; charset="UTF-8"
981 Content-Transfer-Encoding: 8bit
982 Content-Disposition: inline
985 <title>eticket</title>
988 Yes, the text/plain part really was empty.
992 ------=_Part_876302--
995 cat >`mhpath new` <<'EOF'
996 To: recipient@example.com
997 From: sender@example.com
998 Subject: mhfixmsg replacement of bad text/plain part test
1000 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1003 Content-Type: text/plain; charset="iso-8859-15"
1004 Content-Transfer-Encoding: 7bit
1005 Content-Disposition: inline
1010 Content-Type: text/html; charset="UTF-8"
1011 Content-Transfer-Encoding: 8bit
1012 Content-Disposition: inline
1015 <title>eticket</title>
1018 Yes, the text/plain part really was empty.
1022 ------=_Part_876302--
1025 if [ $can_reformat_texthtml -eq 1 ]; then
1026 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
1027 mhfixmsg last
-replacetextplain -outfile - | uniq > "$actual"
1028 check
"$expected" "$actual"
1034 # check -noreplacetextplain
1035 cat >"$expected" <<EOF
1036 To: recipient@example.com
1037 From: sender@example.com
1038 Subject: mhfixmsg replacement of bad text/plain part test
1040 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1043 Content-Type: text/plain; charset="iso-8859-15"
1044 Content-Transfer-Encoding: 7bit
1045 Content-Disposition: inline
1050 Content-Type: text/html; charset="UTF-8"
1051 Content-Transfer-Encoding: 8bit
1052 Content-Disposition: inline
1055 <title>eticket</title>
1058 Yes, the text/plain part really was empty.
1062 ------=_Part_876302--
1065 mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1066 check
"$expected" "$actual"
1070 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1073 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1074 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1075 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1077 run_test
'mhfixmsg 15' ''
1078 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1079 "${MH_TEST_DIR}/Mail/inbox/15.original"
1083 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1085 run_test
'mhfixmsg 19 -normmproc'
1086 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1087 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1091 run_test
'mhfixmsg 20 -rmmproc true'
1092 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1093 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1094 failed
=`expr ${failed:-0} + 1`
1098 # make sure there are no tmp files left over
1099 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1101 cat >"$expected" <<EOF
1104 check
"$expected" "$actual"