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 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
18 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
19 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
20 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
23 if grep mhfixmsg
-format-text/html
"${MH_TEST_DIR}/Mail/mhn.defaults" \
25 can_reformat_texthtml
=1
26 if grep 'mhfixmsg-format-text/html.*w3m' "${MH_TEST_DIR}/Mail/mhn.defaults" \
28 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
29 #### support testing with non-writeable $HOME, and to not leave
30 #### relics from this test if it is writeable but doesn't already
31 #### have a .w3m, and to not depend on whatever is in that if it
32 #### does already exist, overwrite $HOME if using w3m.
37 echo "$0: skipping -reformat check because \
38 mhfixmsg-format-text/html is not available"
39 can_reformat_texthtml
=0
45 # Verified behavior consistent with compiled sendmail.
46 cat >"$expected" <<EOF
47 Usage: mhfixmsg [+folder] [msgs] [switches]
65 mhfixmsg
-help >"$actual" 2>&1
66 check
"$expected" "$actual"
70 # Verified same behavior as compiled mhfixmsg.
71 case `mhfixmsg -version` in
73 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
74 failed
=`expr ${failed:-0} + 1`;;
78 # check that non-MIME messages aren't modified
80 run_test
'mhfixmsg first -outfile '"$actual" ''
81 check
"`mhpath first`" "$actual" 'keep first'
84 # check that non-MIME messages with no bodies aren't modified
86 cat >`mhpath new` <<EOF
87 From: Test <test@example.com>
88 To: Some User <user@example.com>
89 Date: Fri, 29 Sep 2006 00:00:00
91 Subject: message with no body
94 run_test
'mhfixmsg last -outfile '"$actual" ''
95 check
"`mhpath last`" "$actual"
99 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
102 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
103 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
105 Content-Type: MULTIPART/MIXED;
106 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
107 Content-Transfer-Encoding: QUOTED-PRINTABLE
109 This message is in MIME format. The first part should be readable
111 while the remaining parts are likely unreadable without MIME-aware
114 ------=_NextPart_000_0000_00000000.00000000
115 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
116 Content-Transfer-Encoding: 8BIT
118 Some text in swedish.
120 Varf=C3=B6r inte anv=C3=A4nda...
122 ------=_NextPart_000_0000_00000000.00000000--
124 And some text after the last part.
127 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
129 run_test
'mhfixmsg last -nofixcte' ''
130 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
133 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
135 cat >"$expected" <<EOF
138 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
139 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
141 Content-Type: MULTIPART/MIXED;
142 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
143 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
144 Content-Transfer-Encoding: 8bit
146 This message is in MIME format. The first part should be readable
148 while the remaining parts are likely unreadable without MIME-aware
151 ------=_NextPart_000_0000_00000000.00000000
152 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
153 Content-Transfer-Encoding: 8BIT
155 Some text in swedish.
157 Varf=C3=B6r inte anv=C3=A4nda...
159 ------=_NextPart_000_0000_00000000.00000000--
161 And some text after the last part.
164 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
165 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
166 QUOTED-PRINTABLE with 8 bit"
167 check
"$expected" "$actual" 'keep first'
170 # check with no options: checks backup
171 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
172 folder last
>/dev
/null
173 run_test
'mhfixmsg' ''
174 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
175 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
176 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
179 # check backup with -file
180 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
181 folder last
>/dev
/null
182 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
183 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
184 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
187 # check -reformat (enabled by default): addition of text/plain part
188 # to solitary text/html part
190 cat >"$expected" <<EOF
192 From: sender@example.com
193 To: bonquiqui@example.com
195 Date: Sat, 26 Jan 2013 17:37:53 -0500
196 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
198 ------=_nmh-multipart
199 Content-Type: text/plain; charset="Windows-1252"
200 Content-Transfer-Encoding: 8bit
202 Need to go! Need ... to ... go!
204 ------=_nmh-multipart
205 Content-Type: text/html; charset="Windows-1252"
206 Content-Transfer-Encoding: 8bit
210 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
211 <meta name="Generator" content="Microsoft Exchange Server">
212 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
216 <div>Need to go! Need ... to ... go!</div>
220 ------=_nmh-multipart--
223 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
225 From: sender@example.com
226 To: bonquiqui@example.com
228 Date: Sat, 26 Jan 2013 17:37:53 -0500
229 Content-Type: text/html; charset="Windows-1252"
230 Content-Transfer-Encoding: quoted-printable
234 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
236 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
237 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
238 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
242 <div>Need to go! Need ... to ... go!</div>
247 if [ $can_reformat_texthtml -eq 1 ]; then
248 printf '%s\n' "mhfixmsg: 12, insert text/plain part
249 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
252 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
253 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
254 check
"$expected" "$actual"
255 check
"$expected.err" "$actual.err"
261 # check implicit -file with absolute pathname
262 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
265 # check handling of boundary string that appears in message body
267 cat >"$expected" <<EOF
269 From: sender@example.com
270 To: bonquiqui@example.com
272 Date: Sat, 26 Jan 2013 17:37:53 -0500
273 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
275 ------=_nmh-multipart-3
276 Content-Type: text/plain; charset="Windows-1252"
277 Content-Transfer-Encoding: 8bit
279 ------=_nmh-multipart
280 ------=_nmh-multipart-1
281 ------=_nmh-multipart-2
283 ------=_nmh-multipart-3
284 Content-Type: text/html; charset="Windows-1252"
285 Content-Transfer-Encoding: 8bit
289 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
290 <meta name="Generator" content="Microsoft Exchange Server">
291 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
294 ------=_nmh-multipart<br>
295 ------=_nmh-multipart-1<br>
296 ------=_nmh-multipart-2<br>
300 ------=_nmh-multipart-3--
303 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
305 From: sender@example.com
306 To: bonquiqui@example.com
308 Date: Sat, 26 Jan 2013 17:37:53 -0500
309 Content-Type: text/html; charset="Windows-1252"
310 Content-Transfer-Encoding: quoted-printable
314 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
316 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
317 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
318 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
321 ------=3D_nmh-multipart<br>
322 ------=3D_nmh-multipart-1<br>
323 ------=3D_nmh-multipart-2<br>
328 if [ $can_reformat_texthtml -eq 1 ]; then
329 printf '%s\n' "mhfixmsg: 12, insert text/plain part
330 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
333 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
334 mhfixmsg last
-outfile - -verbose 2>"$actual.err" | uniq >"$actual"
335 check
"$expected" "$actual"
336 check
"$expected.err" "$actual.err"
343 cat >"$expected" <<EOF
345 From: sender@example.com
346 To: bonquiqui@example.com
348 Date: Sat, 26 Jan 2013 17:37:53 -0500
349 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
351 ------=_nmh-multipart
352 Content-Type: text/plain; charset="Windows-1252"
353 Content-Transfer-Encoding: 8bit
355 Need to go! Need ... to ... go!
357 ------=_nmh-multipart
358 Content-Type: text/html; charset="Windows-1252"
359 Content-Transfer-Encoding: quoted-printable
363 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
365 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
366 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
367 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
371 <div>Need to go! Need ... to ... go!</div>
375 ------=_nmh-multipart--
378 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
380 From: sender@example.com
381 To: bonquiqui@example.com
383 Date: Sat, 26 Jan 2013 17:37:53 -0500
384 Content-Type: text/html; charset="Windows-1252"
385 Content-Transfer-Encoding: quoted-printable
389 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
391 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
392 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
393 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
397 <div>Need to go! Need ... to ... go!</div>
402 if [ $can_reformat_texthtml -eq 1 ]; then
403 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
405 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
406 mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | uniq >"$actual"
407 check
"$expected" "$actual"
408 check
"$expected.err" "$actual.err"
414 # check -decode (enabled by default)
415 cat >"$expected" <<EOF
416 To: recipient@example.com
417 From: sender@example.com
418 Subject: mhfixmsg decode test
420 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
422 ------- =_aaaaaaaaaa0
423 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
424 Content-Disposition: attachment; filename="test4.txt"
425 Content-Transfer-Encoding: 8bit
427 This is a text/plain part.
429 ------- =_aaaaaaaaaa0--
432 cat >`mhpath new` <<EOF
433 To: recipient@example.com
434 From: sender@example.com
435 Subject: mhfixmsg decode test
437 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
439 ------- =_aaaaaaaaaa0
440 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
441 Content-Disposition: attachment; filename="test4.txt"
442 Content-Transfer-Encoding: base64
444 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
446 ------- =_aaaaaaaaaa0--
449 mhfixmsg last
-outfile "$actual"
450 check
"$expected" "$actual"
453 # check -decode with more complicated content structure
455 To: recipient@example.com
456 From: sender@example.com
457 Subject: mhfixmsg decode test 2
459 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
461 This is additional content before the first subpart of the multipart.
463 ------- =_aaaaaaaaaa0
464 Content-Type: multipart/related;
465 type="multipart/alternative";
466 boundary="subpart__1.1"
469 Content-Type: text/plain; charset="iso-8859-1"
470 Content-Disposition: attachment; filename="test1.txt"
472 This is the first text/plain part, in a subpart.
476 This is additional content after the last subpart of the multipart.
478 ------- =_aaaaaaaaaa0
479 Content-Type: text/plain; charset="iso-8859-1"
480 Content-Disposition: attachment; filename="test2.txt"
481 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
482 Content-Transfer-Encoding: 8bit
484 This is the second text/plain part.
486 ------- =_aaaaaaaaaa0
487 Content-Type: text/plain; charset="iso-8859-1"
488 Content-Disposition: attachment; filename="test3.txt"
490 This is the third text/plain part.
492 ------- =_aaaaaaaaaa0
493 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
494 Content-Disposition: attachment; filename="test4.txt"
495 Content-Transfer-Encoding: 8bit
497 This is the fourth text/plain part.
499 ------- =_aaaaaaaaaa0--
501 This is additional content after the last subpart of the multipart.
504 cat >`mhpath new` <<EOF
505 To: recipient@example.com
506 From: sender@example.com
507 Subject: mhfixmsg decode test 2
509 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
511 This is additional content before the first subpart of the multipart.
513 ------- =_aaaaaaaaaa0
514 Content-Type: multipart/related;
515 type="multipart/alternative";
516 boundary="subpart__1.1"
519 Content-Type: text/plain; charset="iso-8859-1"
520 Content-Disposition: attachment; filename="test1.txt"
522 This is the first text/plain part, in a subpart.
526 This is additional content after the last subpart of the multipart.
528 ------- =_aaaaaaaaaa0
529 Content-Type: text/plain; charset="iso-8859-1"
530 Content-Disposition: attachment; filename="test2.txt"
531 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
532 Content-Transfer-Encoding: quoted-printable
534 This is the second text/plain part.
536 ------- =_aaaaaaaaaa0
537 Content-Type: text/plain; charset="iso-8859-1"
538 Content-Disposition: attachment; filename="test3.txt"
540 This is the third text/plain part.
542 ------- =_aaaaaaaaaa0
543 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
544 Content-Disposition: attachment; filename="test4.txt"
545 Content-Transfer-Encoding: base64
547 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
549 ------- =_aaaaaaaaaa0--
551 This is additional content after the last subpart of the multipart.
553 mhfixmsg last
-outfile "$actual"
554 check
"$expected" "$actual"
557 # check attempted -decode of binary text
558 #### Generated the encoded text below with:
559 #### $ printf '\x0d\xbd\xb2=\xbc\n' | base64
560 cat >`mhpath new` <<EOF
561 To: recipient@example.com
562 From: sender@example.com
563 Subject: mhfixmsg attempted binary decode test
565 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
567 ------- =_aaaaaaaaaa0
568 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
569 Content-Transfer-Encoding: base64
573 ------- =_aaaaaaaaaa0--
576 cp -p `mhpath last` "$expected"
580 check
`mhpath last` "$expected" 'keep first'
583 # check -decode of binary text
584 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
585 From: sender@example.com
586 Subject: mhfixmsg binary decode test
588 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
590 ------- =_aaaaaaaaaa0
591 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"square.txt\"
592 Content-Transfer-Encoding: binary
596 ------- =_aaaaaaaaaa0--
598 ## output_content() in mhoutsbr.c can't handle binary content.
599 ## mhfixmsg last -decodetext binary -outfile "$actual"
600 ## check "$expected" "$actual"
605 # check that -reformat succeeds when decode of binary text fails
606 cat >"$expected" <<'EOF'
608 Date: Thu, 11 Apr 2013 02:47:08 -0700
610 From: <sender@example.com>
611 Subject: body requires binary encoding
612 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
614 ------=_nmh-multipart
615 Content-Type: text/plain; charset="ISO-8859-1"
616 Content-Transfer-Encoding: 8bit
621 Vehicle License Fee $1.84
624 ------=_nmh-multipart
625 Content-Type: text/html; charset="ISO-8859-1"
626 Content-Transfer-Encoding: quoted-printable
631 cat >`mhpath new` <<'EOF'
633 Content-Type: text/html; charset="ISO-8859-1"
634 Content-Transfer-Encoding: quoted-printable
635 Date: Thu, 11 Apr 2013 02:47:08 -0700
637 From: <sender@example.com>
638 Subject: body requires binary encoding
641 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
642 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
643 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
644 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
645 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
646 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
647 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
648 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
649 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
650 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
651 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
652 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
653 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
654 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
655 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
656 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
657 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
658 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
659 #333333" size=3D"2">$6.00</font></td></tr>
665 if [ $can_reformat_texthtml -eq 1 ]; then
666 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
667 #### Truncate to avoid comparing the html portion because it can
668 #### get reformatted.
669 mhfixmsg last
-outfile - | uniq | head -22 >"$actual"
670 check
"$expected" "$actual" 'ignore space'
672 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
678 # Also checks preservation of attributes after one (charset) that is
680 cat >"$expected" <<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="utf-8"; name="square.txt"
689 Content-Disposition: attachment; filename="square.txt"
690 Content-Transfer-Encoding: 8bit
694 ------- =_aaaaaaaaaa0--
697 #### Generated the encoded text below with:
698 #### $ printf '\xbd\xb2=\xbc\n' | base64
699 cat >`mhpath new` <<EOF
700 To: recipient@example.com
701 From: sender@example.com
702 Subject: mhfixmsg textcodeset test
704 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
706 ------- =_aaaaaaaaaa0
707 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
708 Content-Disposition: attachment; filename="square.txt"
709 Content-Transfer-Encoding: base64
713 ------- =_aaaaaaaaaa0--
717 mhfixmsg last
-textcodeset utf
-8 -outfile "$actual" 2>"$actual.err"
718 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
720 echo "$0: skipping -textcodeset check because nmh was built without iconv"
721 rm -f "$expected" "$actual" "$actual.err"
723 check
"$expected" "$actual"
729 # check -nofixboundary
730 cat >"$expected" <<EOF
733 cat >`mhpath new` <<EOF
734 Date: Fri, 13 May 2011 08:21:12 -0500
735 Content-Type: multipart/alternative;
736 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
737 Content-Transfer-Encoding: 8bit
739 From: <sender@example.com>
740 To: <recipient@example.com>
741 Subject: mhfixmsg bad boundary test
743 This is a multi-part message in MIME format.
745 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
746 Content-Type: text/plain
748 The boundaries of this part don't match the header boundary.
750 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
753 cp -p `mhpath last` `mhpath new`
755 run_test
'mhfixmsg last -nofixboundary' ''
756 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
759 # check that message is not output when fed through stdin
760 mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
761 check
"$expected" "$actual"
762 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
763 "$actual.err" >/dev
/null
; then
766 echo "$0: test failed, output is in $actual.err."
767 failed
=`expr ${failed:-0} + 1`
771 # check fixup of erroneous boundary in multipart (-fixboundary,
772 # enabled by default)
774 cat >"$expected" <<EOF
775 Date: Fri, 13 May 2011 08:21:12 -0500
776 Content-Type: multipart/alternative;
777 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
778 Content-Transfer-Encoding: 8bit
780 From: <sender@example.com>
781 To: <recipient@example.com>
782 Subject: mhfixmsg bad boundary test
784 This is a multi-part message in MIME format.
786 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
787 Content-Type: text/plain
789 The boundaries of this part don't match the header boundary.
791 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
794 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
795 "mhfixmsg: 17, fix multipart boundary"
796 check
"$expected" "$actual"
799 # check that text/plain part is added to lone text/html in multipart/related
800 cat >"$expected" <<EOF
802 Date: Tue, 26 Feb 2013 18:07:20 -0600
803 Subject: multipart/related, not /alternative
804 Content-Type: multipart/related;
805 boundary="----=_Part_90310_101292502.1"
807 ------=_Part_90310_101292502.1
808 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
810 ------=_nmh-multipart1
811 Content-Type: text/plain; charset="us-ascii"
812 Content-Transfer-Encoding: 7bit
814 This is the real content.
816 ------=_nmh-multipart1
817 Content-Type: text/html; charset="us-ascii"
818 Content-Transfer-Encoding: 7bit
821 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
822 <title>HTML Content</title>
825 This is the real content.
829 ------=_nmh-multipart1--
831 ------=_Part_90310_101292502.1
832 Content-Type: text/plain; charset="us-ascii"
833 Content-Transfer-Encoding: 7bit
835 Your email client does not support HTML messages
837 ------=_Part_90310_101292502.1--
840 cat >`mhpath new` <<EOF
842 Date: Tue, 26 Feb 2013 18:07:20 -0600
843 Subject: multipart/related, not /alternative
844 Content-Type: multipart/related;
845 boundary="----=_Part_90310_101292502.1"
847 ------=_Part_90310_101292502.1
848 Content-Type: text/html; charset="us-ascii"
849 Content-Transfer-Encoding: 7bit
852 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
853 <title>HTML Content</title>
856 This is the real content.
859 ------=_Part_90310_101292502.1
860 Content-Type: text/plain; charset="us-ascii"
861 Content-Transfer-Encoding: 7bit
863 Your email client does not support HTML messages
864 ------=_Part_90310_101292502.1--
867 if [ $can_reformat_texthtml -eq 1 ]; then
868 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
869 mhfixmsg last
-outfile - | uniq >"$actual"
870 check
"$expected" "$actual"
876 # check handling of rfc822 message type
877 cat >"$expected" <<EOF
878 From: Test <test@example.com>
879 To: Some User <user@example.com>
880 Date: Fri, 29 Sep 2006 00:00:00
881 Message-Id: @test.nmh
882 Subject: message with message/rfc822 attachment
884 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
886 and some garbage before the attachment
888 ------- =_aaaaaaaaaa0
889 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
890 Content-Description: 1552
891 Content-Disposition: attachment; filename="1552"
893 From: Test <test@example.com>
894 To: <another_user@example.com>
895 Date: Thu, 28 Sep 2006 00:00:00
896 Message-Id: @test.nmh
897 Subject: message/rfc822 attachment
899 This is an RFC-822 message.
901 ------- =_aaaaaaaaaa0--
903 and some garbage at the end
906 cat >`mhpath new` <<EOF
907 From: Test <test@example.com>
908 To: Some User <user@example.com>
909 Date: Fri, 29 Sep 2006 00:00:00
910 Message-Id: @test.nmh
911 Subject: message with message/rfc822 attachment
913 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
915 and some garbage before the attachment
917 ------- =_aaaaaaaaaa0
918 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
919 Content-Description: 1552
920 Content-Disposition: attachment; filename="1552"
922 From: Test <test@example.com>
923 To: <another_user@example.com>
924 Date: Thu, 28 Sep 2006 00:00:00
925 Message-Id: @test.nmh
926 Subject: message/rfc822 attachment
928 This is an RFC-822 message.
930 ------- =_aaaaaaaaaa0--
932 and some garbage at the end
935 run_test
'mhfixmsg last -outfile '"$actual" ''
936 check
"$expected" "$actual"
939 # check stripping of CRs from ASCII text context
940 cat >"$expected" <<EOF
942 From: sender@example.com
943 To: recipient@example.com
944 Subject: message with CR's
945 Date: Mon, 29 Apr 2013 11:51:45 -0400
947 There are two CR-LF pairs at the end of this sentence.
951 cat >`mhpath new` <<'EOF'
953 From: sender@example.com
954 To: recipient@example.com
955 Subject: message with CR's
956 Date: Mon, 29 Apr 2013 11:51:45 -0400
958 There are two CR-LF pairs at the end of this sentence.
962 mhfixmsg last
-outfile "$actual"
963 check
"$expected" "$actual"
966 # check -replacetextplain
967 cat >"$expected" <<EOF
968 To: recipient@example.com
969 From: sender@example.com
970 Subject: mhfixmsg replacement of bad text/plain part test
972 Content-Type: multipart/alternative; boundary="----=_Part_876302"
975 Content-Type: text/plain; charset="UTF-8"
976 Content-Transfer-Encoding: 8bit
978 Yes, the text/plain part really was empty.
981 Content-Type: text/html; charset="UTF-8"
982 Content-Transfer-Encoding: 8bit
983 Content-Disposition: inline
986 <title>eticket</title>
989 Yes, the text/plain part really was empty.
993 ------=_Part_876302--
996 cat >`mhpath new` <<'EOF'
997 To: recipient@example.com
998 From: sender@example.com
999 Subject: mhfixmsg replacement of bad text/plain part test
1001 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1004 Content-Type: text/plain; charset="iso-8859-15"
1005 Content-Transfer-Encoding: 7bit
1006 Content-Disposition: inline
1011 Content-Type: text/html; charset="UTF-8"
1012 Content-Transfer-Encoding: 8bit
1013 Content-Disposition: inline
1016 <title>eticket</title>
1019 Yes, the text/plain part really was empty.
1023 ------=_Part_876302--
1026 if [ $can_reformat_texthtml -eq 1 ]; then
1027 #### lynx inserts multiple blank lines, so use uniq to squeeze them.
1028 mhfixmsg last
-replacetextplain -outfile - | uniq > "$actual"
1029 check
"$expected" "$actual"
1035 # check -noreplacetextplain
1036 cat >"$expected" <<EOF
1037 To: recipient@example.com
1038 From: sender@example.com
1039 Subject: mhfixmsg replacement of bad text/plain part test
1041 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1044 Content-Type: text/plain; charset="iso-8859-15"
1045 Content-Transfer-Encoding: 7bit
1046 Content-Disposition: inline
1051 Content-Type: text/html; charset="UTF-8"
1052 Content-Transfer-Encoding: 8bit
1053 Content-Disposition: inline
1056 <title>eticket</title>
1059 Yes, the text/plain part really was empty.
1063 ------=_Part_876302--
1066 mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1067 check
"$expected" "$actual"
1071 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1074 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1075 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1076 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1078 run_test
'mhfixmsg 15' ''
1079 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1080 "${MH_TEST_DIR}/Mail/inbox/15.original"
1084 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1086 run_test
'mhfixmsg 19 -normmproc'
1087 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1088 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1092 run_test
'mhfixmsg 20 -rmmproc true'
1093 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1094 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1095 failed
=`expr ${failed:-0} + 1`
1099 # make sure there are no tmp files left over
1100 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1102 cat >"$expected" <<EOF
1105 check
"$expected" "$actual"