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"
22 #### Make sure that html-to-text conversion is what we expect.
23 LC_ALL
=en_US.UTF
-8; export LC_ALL
26 if grep mhfixmsg
-format-text/html
"${MH_TEST_DIR}/Mail/mhn.defaults" \
28 can_reformat_texthtml
=1
29 if grep 'mhfixmsg-format-text/html.*w3m' "${MH_TEST_DIR}/Mail/mhn.defaults" \
31 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
32 #### support testing with non-writeable $HOME, and to not leave
33 #### relics from this test if it is writeable but doesn't already
34 #### have a .w3m, and to not depend on whatever is in that if it
35 #### does already exist, overwrite $HOME if using w3m.
40 echo "$0: skipping -reformat check because \
41 mhfixmsg-format-text/html is not available"
42 can_reformat_texthtml
=0
48 # Verified behavior consistent with compiled sendmail.
49 cat >"$expected" <<EOF
50 Usage: mhfixmsg [+folder] [msgs] [switches]
68 run_prog mhfixmsg
-help >"$actual" 2>&1
69 check
"$expected" "$actual"
73 # Verified same behavior as compiled mhfixmsg.
74 case `mhfixmsg -version` in
76 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
77 failed
=`expr ${failed:-0} + 1`;;
81 # check that non-MIME messages aren't modified
83 run_test
'mhfixmsg first -outfile '"$actual" ''
84 check
"`mhpath first`" "$actual" 'keep first'
87 # check that non-MIME messages with no bodies aren't modified
89 cat >`mhpath new` <<EOF
90 From: Test <test@example.com>
91 To: Some User <user@example.com>
92 Date: Fri, 29 Sep 2006 00:00:00
94 Subject: message with no body
97 run_test
'mhfixmsg last -outfile '"$actual" ''
98 check
"`mhpath last`" "$actual"
102 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
105 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
106 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
108 Content-Type: MULTIPART/MIXED;
109 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
110 Content-Transfer-Encoding: QUOTED-PRINTABLE
112 This message is in MIME format. The first part should be readable
114 while the remaining parts are likely unreadable without MIME-aware
117 ------=_NextPart_000_0000_00000000.00000000
118 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
119 Content-Transfer-Encoding: 8BIT
121 Some text in swedish.
123 Varf=C3=B6r inte anv=C3=A4nda...
125 ------=_NextPart_000_0000_00000000.00000000--
127 And some text after the last part.
130 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
132 run_test
'mhfixmsg last -nofixcte' ''
133 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
136 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
138 cat >"$expected" <<EOF
141 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
142 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
144 Content-Type: MULTIPART/MIXED;
145 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
146 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
147 Content-Transfer-Encoding: 8bit
149 This message is in MIME format. The first part should be readable
151 while the remaining parts are likely unreadable without MIME-aware
154 ------=_NextPart_000_0000_00000000.00000000
155 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
156 Content-Transfer-Encoding: 8BIT
158 Some text in swedish.
160 Varf=C3=B6r inte anv=C3=A4nda...
162 ------=_NextPart_000_0000_00000000.00000000--
164 And some text after the last part.
167 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
168 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
169 QUOTED-PRINTABLE with 8 bit"
170 check
"$expected" "$actual" 'keep first'
173 # check with no options: checks backup
174 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
175 folder last
>/dev
/null
176 run_test
'mhfixmsg' ''
177 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
178 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
179 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
182 # check backup with -file
183 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
184 folder last
>/dev
/null
185 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
186 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
187 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
190 # check -reformat (enabled by default): addition of text/plain part
191 # to solitary text/html part
193 prepare_space
>"$expected" <<EOF
195 From: sender@example.com
196 To: bonquiqui@example.com
198 Date: Sat, 26 Jan 2013 17:37:53 -0500
199 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
201 ------=_nmh-multipart
202 Content-Type: text/plain; charset="Windows-1252"
203 Content-Transfer-Encoding: 8bit
205 Need to go! Need ... to ... go!
207 ------=_nmh-multipart
208 Content-Type: text/html; charset="Windows-1252"
209 Content-Transfer-Encoding: 8bit
213 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
214 <meta name="Generator" content="Microsoft Exchange Server">
215 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
219 <div>Need to go! Need ... to ... go!</div>
223 ------=_nmh-multipart--
226 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
228 From: sender@example.com
229 To: bonquiqui@example.com
231 Date: Sat, 26 Jan 2013 17:37:53 -0500
232 Content-Type: text/html; charset="Windows-1252"
233 Content-Transfer-Encoding: quoted-printable
237 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
239 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
240 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
241 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
245 <div>Need to go! Need ... to ... go!</div>
250 if [ $can_reformat_texthtml -eq 1 ]; then
251 printf '%s\n' "mhfixmsg: 12, insert text/plain part
252 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
255 #### lynx inserts multiple blank lines, so squeeze them.
256 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
257 squeeze_lines
>"$actual"
258 check
"$expected" "$actual" 'ignore space'
259 check
"$expected.err" "$actual.err"
265 # check implicit -file with absolute pathname
266 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
269 # check handling of boundary string that appears in message body
271 prepare_space
>"$expected" <<EOF
273 From: sender@example.com
274 To: bonquiqui@example.com
276 Date: Sat, 26 Jan 2013 17:37:53 -0500
277 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
279 ------=_nmh-multipart-3
280 Content-Type: text/plain; charset="Windows-1252"
281 Content-Transfer-Encoding: 8bit
283 ------=_nmh-multipart
284 ------=_nmh-multipart-1
285 ------=_nmh-multipart-2
287 ------=_nmh-multipart-3
288 Content-Type: text/html; charset="Windows-1252"
289 Content-Transfer-Encoding: 8bit
293 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
294 <meta name="Generator" content="Microsoft Exchange Server">
295 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
298 ------=_nmh-multipart<br>
299 ------=_nmh-multipart-1<br>
300 ------=_nmh-multipart-2<br>
304 ------=_nmh-multipart-3--
307 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
309 From: sender@example.com
310 To: bonquiqui@example.com
312 Date: Sat, 26 Jan 2013 17:37:53 -0500
313 Content-Type: text/html; charset="Windows-1252"
314 Content-Transfer-Encoding: quoted-printable
318 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
320 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
321 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
322 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
325 ------=3D_nmh-multipart<br>
326 ------=3D_nmh-multipart-1<br>
327 ------=3D_nmh-multipart-2<br>
332 if [ $can_reformat_texthtml -eq 1 ]; then
333 printf '%s\n' "mhfixmsg: 12, insert text/plain part
334 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
337 #### lynx inserts multiple blank lines, so squeeze them.
338 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
339 squeeze_lines
>"$actual"
340 check
"$expected" "$actual" 'ignore space'
341 check
"$expected.err" "$actual.err"
348 prepare_space
>"$expected" <<EOF
350 From: sender@example.com
351 To: bonquiqui@example.com
353 Date: Sat, 26 Jan 2013 17:37:53 -0500
354 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
356 ------=_nmh-multipart
357 Content-Type: text/plain; charset="Windows-1252"
358 Content-Transfer-Encoding: 8bit
360 Need to go! Need ... to ... go!
362 ------=_nmh-multipart
363 Content-Type: text/html; charset="Windows-1252"
364 Content-Transfer-Encoding: quoted-printable
368 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
370 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
371 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
372 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
376 <div>Need to go! Need ... to ... go!</div>
380 ------=_nmh-multipart--
383 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
385 From: sender@example.com
386 To: bonquiqui@example.com
388 Date: Sat, 26 Jan 2013 17:37:53 -0500
389 Content-Type: text/html; charset="Windows-1252"
390 Content-Transfer-Encoding: quoted-printable
394 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
396 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
397 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
398 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
402 <div>Need to go! Need ... to ... go!</div>
407 if [ $can_reformat_texthtml -eq 1 ]; then
408 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
410 #### lynx inserts multiple blank lines, so squeeze them.
411 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
412 squeeze_lines
>"$actual"
413 check
"$expected" "$actual" 'ignore space'
414 check
"$expected.err" "$actual.err"
420 # check -decode (enabled by default)
421 cat >"$expected" <<EOF
422 To: recipient@example.com
423 From: sender@example.com
424 Subject: mhfixmsg decode test
426 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
428 ------- =_aaaaaaaaaa0
429 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
430 Content-Disposition: attachment; filename="test4.txt"
431 Content-Transfer-Encoding: 8bit
433 This is a text/plain part.
435 ------- =_aaaaaaaaaa0--
438 cat >`mhpath new` <<EOF
439 To: recipient@example.com
440 From: sender@example.com
441 Subject: mhfixmsg decode test
443 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
445 ------- =_aaaaaaaaaa0
446 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
447 Content-Disposition: attachment; filename="test4.txt"
448 Content-Transfer-Encoding: base64
450 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
452 ------- =_aaaaaaaaaa0--
455 run_prog mhfixmsg last
-outfile "$actual"
456 check
"$expected" "$actual"
459 # check -decode with more complicated content structure
461 To: recipient@example.com
462 From: sender@example.com
463 Subject: mhfixmsg decode test 2
465 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
467 This is additional content before the first subpart of the multipart.
469 ------- =_aaaaaaaaaa0
470 Content-Type: multipart/related;
471 type="multipart/alternative";
472 boundary="subpart__1.1"
475 Content-Type: text/plain; charset="iso-8859-1"
476 Content-Disposition: attachment; filename="test1.txt"
478 This is the first text/plain part, in a subpart.
482 This is additional content after the last subpart of the multipart.
484 ------- =_aaaaaaaaaa0
485 Content-Type: text/plain; charset="iso-8859-1"
486 Content-Disposition: attachment; filename="test2.txt"
487 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
488 Content-Transfer-Encoding: 8bit
490 This is the second text/plain part.
492 ------- =_aaaaaaaaaa0
493 Content-Type: text/plain; charset="iso-8859-1"
494 Content-Disposition: attachment; filename="test3.txt"
496 This is the third text/plain part.
498 ------- =_aaaaaaaaaa0
499 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
500 Content-Disposition: attachment; filename="test4.txt"
501 Content-Transfer-Encoding: 8bit
503 This is the fourth text/plain part.
505 ------- =_aaaaaaaaaa0--
507 This is additional content after the last subpart of the multipart.
510 cat >`mhpath new` <<EOF
511 To: recipient@example.com
512 From: sender@example.com
513 Subject: mhfixmsg decode test 2
515 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
517 This is additional content before the first subpart of the multipart.
519 ------- =_aaaaaaaaaa0
520 Content-Type: multipart/related;
521 type="multipart/alternative";
522 boundary="subpart__1.1"
525 Content-Type: text/plain; charset="iso-8859-1"
526 Content-Disposition: attachment; filename="test1.txt"
528 This is the first text/plain part, in a subpart.
532 This is additional content after the last subpart of the multipart.
534 ------- =_aaaaaaaaaa0
535 Content-Type: text/plain; charset="iso-8859-1"
536 Content-Disposition: attachment; filename="test2.txt"
537 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
538 Content-Transfer-Encoding: quoted-printable
540 This is the second text/plain part.
542 ------- =_aaaaaaaaaa0
543 Content-Type: text/plain; charset="iso-8859-1"
544 Content-Disposition: attachment; filename="test3.txt"
546 This is the third text/plain part.
548 ------- =_aaaaaaaaaa0
549 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
550 Content-Disposition: attachment; filename="test4.txt"
551 Content-Transfer-Encoding: base64
553 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
555 ------- =_aaaaaaaaaa0--
557 This is additional content after the last subpart of the multipart.
559 run_prog mhfixmsg last
-outfile "$actual"
560 check
"$expected" "$actual"
563 # check attempted -decode of binary text
564 #### Generated the encoded text below with:
565 #### $ printf '\x0d\xbd\xb2=\xbc\n' | base64
566 cat >`mhpath new` <<EOF
567 To: recipient@example.com
568 From: sender@example.com
569 Subject: mhfixmsg attempted binary decode test
571 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
573 ------- =_aaaaaaaaaa0
574 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
575 Content-Transfer-Encoding: base64
579 ------- =_aaaaaaaaaa0--
582 cp -p `mhpath last` "$expected"
584 run_prog mhfixmsg last
586 check
`mhpath last` "$expected" 'keep first'
589 # check -decode of binary text
590 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
591 From: sender@example.com
592 Subject: mhfixmsg binary decode test
594 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
596 ------- =_aaaaaaaaaa0
597 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"square.txt\"
598 Content-Transfer-Encoding: binary
602 ------- =_aaaaaaaaaa0--
604 ## output_content() in mhoutsbr.c can't handle binary content.
605 ## mhfixmsg last -decodetext binary -outfile "$actual"
606 ## check "$expected" "$actual"
611 # check that -reformat succeeds when decode of binary text fails
612 prepare_space
>"$expected" <<'EOF'
614 Date: Thu, 11 Apr 2013 02:47:08 -0700
616 From: <sender@example.com>
617 Subject: body requires binary encoding
618 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
620 ------=_nmh-multipart
621 Content-Type: text/plain; charset="ISO-8859-1"
622 Content-Transfer-Encoding: 8bit
627 Vehicle License Fee $1.84
630 ------=_nmh-multipart
631 Content-Type: text/html; charset="ISO-8859-1"
632 Content-Transfer-Encoding: quoted-printable
637 cat >`mhpath new` <<'EOF'
639 Content-Type: text/html; charset="ISO-8859-1"
640 Content-Transfer-Encoding: quoted-printable
641 Date: Thu, 11 Apr 2013 02:47:08 -0700
643 From: <sender@example.com>
644 Subject: body requires binary encoding
647 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
648 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
649 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
650 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
651 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
652 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
653 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
654 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
655 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
656 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
657 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
658 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
659 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
660 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
661 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
662 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
663 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
664 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
665 #333333" size=3D"2">$6.00</font></td></tr>
671 if [ $can_reformat_texthtml -eq 1 ]; then
672 #### lynx inserts multiple blank lines, so squeeze them.
673 #### Truncate to avoid comparing the html portion because it can
674 #### get reformatted.
675 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
676 check
"$expected" "$actual" 'ignore space'
678 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
684 # Also checks preservation of attributes after one (charset) that is
686 cat >"$expected" <<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="utf-8"; name="square.txt"
695 Content-Disposition: attachment; filename="square.txt"
696 Content-Transfer-Encoding: 8bit
700 ------- =_aaaaaaaaaa0--
703 #### Generated the encoded text below with:
704 #### $ printf '\xbd\xb2=\xbc\n' | base64
705 cat >`mhpath new` <<EOF
706 To: recipient@example.com
707 From: sender@example.com
708 Subject: mhfixmsg textcodeset test
710 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
712 ------- =_aaaaaaaaaa0
713 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
714 Content-Disposition: attachment; filename="square.txt"
715 Content-Transfer-Encoding: base64
719 ------- =_aaaaaaaaaa0--
723 run_prog mhfixmsg last
-textcodeset utf
-8 -outfile "$actual" 2>"$actual.err"
724 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
726 echo "$0: skipping -textcodeset check because nmh was built without iconv"
727 rm -f "$expected" "$actual" "$actual.err"
729 check
"$expected" "$actual"
735 # check -nofixboundary
736 cat >"$expected" <<EOF
739 cat >`mhpath new` <<EOF
740 Date: Fri, 13 May 2011 08:21:12 -0500
741 Content-Type: multipart/alternative;
742 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
743 Content-Transfer-Encoding: 8bit
745 From: <sender@example.com>
746 To: <recipient@example.com>
747 Subject: mhfixmsg bad boundary test
749 This is a multi-part message in MIME format.
751 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
752 Content-Type: text/plain
754 The boundaries of this part don't match the header boundary.
756 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
759 cp -p `mhpath last` `mhpath new`
761 run_test
'mhfixmsg last -nofixboundary' ''
762 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
765 # check that message is not output when fed through stdin
766 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
767 check
"$expected" "$actual"
768 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
769 "$actual.err" >/dev
/null
; then
772 echo "$0: test failed, output is in $actual.err."
773 failed
=`expr ${failed:-0} + 1`
777 # check fixup of erroneous boundary in multipart (-fixboundary,
778 # enabled by default)
780 cat >"$expected" <<EOF
781 Date: Fri, 13 May 2011 08:21:12 -0500
782 Content-Type: multipart/alternative;
783 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
784 Content-Transfer-Encoding: 8bit
786 From: <sender@example.com>
787 To: <recipient@example.com>
788 Subject: mhfixmsg bad boundary test
790 This is a multi-part message in MIME format.
792 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
793 Content-Type: text/plain
795 The boundaries of this part don't match the header boundary.
797 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
800 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
801 "mhfixmsg: 17, fix multipart boundary"
802 check
"$expected" "$actual"
805 # check that text/plain part is added to lone text/html in multipart/related
806 prepare_space
>"$expected" <<EOF
808 Date: Tue, 26 Feb 2013 18:07:20 -0600
809 Subject: multipart/related, not /alternative
810 Content-Type: multipart/related;
811 boundary="----=_Part_90310_101292502.1"
813 ------=_Part_90310_101292502.1
814 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
816 ------=_nmh-multipart1
817 Content-Type: text/plain; charset="us-ascii"
818 Content-Transfer-Encoding: 7bit
820 This is the real content.
822 ------=_nmh-multipart1
823 Content-Type: text/html; charset="us-ascii"
824 Content-Transfer-Encoding: 7bit
827 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
828 <title>HTML Content</title>
831 This is the real content.
835 ------=_nmh-multipart1--
837 ------=_Part_90310_101292502.1
838 Content-Type: text/plain; charset="us-ascii"
839 Content-Transfer-Encoding: 7bit
841 Your email client does not support HTML messages
843 ------=_Part_90310_101292502.1--
846 cat >`mhpath new` <<EOF
848 Date: Tue, 26 Feb 2013 18:07:20 -0600
849 Subject: multipart/related, not /alternative
850 Content-Type: multipart/related;
851 boundary="----=_Part_90310_101292502.1"
853 ------=_Part_90310_101292502.1
854 Content-Type: text/html; charset="us-ascii"
855 Content-Transfer-Encoding: 7bit
858 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
859 <title>HTML Content</title>
862 This is the real content.
865 ------=_Part_90310_101292502.1
866 Content-Type: text/plain; charset="us-ascii"
867 Content-Transfer-Encoding: 7bit
869 Your email client does not support HTML messages
870 ------=_Part_90310_101292502.1--
873 if [ $can_reformat_texthtml -eq 1 ]; then
874 #### lynx inserts multiple blank lines, so squeeze them.
875 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
876 check
"$expected" "$actual" 'ignore space'
882 # check handling of rfc822 message type
883 cat >"$expected" <<EOF
884 From: Test <test@example.com>
885 To: Some User <user@example.com>
886 Date: Fri, 29 Sep 2006 00:00:00
887 Message-Id: @test.nmh
888 Subject: message with message/rfc822 attachment
890 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
892 and some garbage before the attachment
894 ------- =_aaaaaaaaaa0
895 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
896 Content-Description: 1552
897 Content-Disposition: attachment; filename="1552"
899 From: Test <test@example.com>
900 To: <another_user@example.com>
901 Date: Thu, 28 Sep 2006 00:00:00
902 Message-Id: @test.nmh
903 Subject: message/rfc822 attachment
905 This is an RFC-822 message.
907 ------- =_aaaaaaaaaa0--
909 and some garbage at the end
912 cat >`mhpath new` <<EOF
913 From: Test <test@example.com>
914 To: Some User <user@example.com>
915 Date: Fri, 29 Sep 2006 00:00:00
916 Message-Id: @test.nmh
917 Subject: message with message/rfc822 attachment
919 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
921 and some garbage before the attachment
923 ------- =_aaaaaaaaaa0
924 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
925 Content-Description: 1552
926 Content-Disposition: attachment; filename="1552"
928 From: Test <test@example.com>
929 To: <another_user@example.com>
930 Date: Thu, 28 Sep 2006 00:00:00
931 Message-Id: @test.nmh
932 Subject: message/rfc822 attachment
934 This is an RFC-822 message.
936 ------- =_aaaaaaaaaa0--
938 and some garbage at the end
941 run_test
'mhfixmsg last -outfile '"$actual" ''
942 check
"$expected" "$actual"
945 # check stripping of CRs from ASCII text context
946 cat >"$expected" <<EOF
948 From: sender@example.com
949 To: recipient@example.com
950 Subject: message with CR's
951 Date: Mon, 29 Apr 2013 11:51:45 -0400
953 There are two CR-LF pairs at the end of this sentence.
957 cat >`mhpath new` <<'EOF'
959 From: sender@example.com
960 To: recipient@example.com
961 Subject: message with CR's
962 Date: Mon, 29 Apr 2013 11:51:45 -0400
964 There are two CR-LF pairs at the end of this sentence.
968 run_prog mhfixmsg last
-outfile "$actual"
969 check
"$expected" "$actual"
972 # check -replacetextplain
973 prepare_space
>"$expected" <<EOF
974 To: recipient@example.com
975 From: sender@example.com
976 Subject: mhfixmsg replacement of bad text/plain part test
978 Content-Type: multipart/alternative; boundary="----=_Part_876302"
981 Content-Type: text/plain; charset="UTF-8"
982 Content-Transfer-Encoding: 8bit
984 Yes, the text/plain part really was empty.
987 Content-Type: text/html; charset="UTF-8"
988 Content-Transfer-Encoding: 8bit
989 Content-Disposition: inline
992 <title>eticket</title>
995 Yes, the text/plain part really was empty.
999 ------=_Part_876302--
1002 cat >`mhpath new` <<'EOF'
1003 To: recipient@example.com
1004 From: sender@example.com
1005 Subject: mhfixmsg replacement of bad text/plain part test
1007 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1010 Content-Type: text/plain; charset="iso-8859-15"
1011 Content-Transfer-Encoding: 7bit
1012 Content-Disposition: inline
1017 Content-Type: text/html; charset="UTF-8"
1018 Content-Transfer-Encoding: 8bit
1019 Content-Disposition: inline
1022 <title>eticket</title>
1025 Yes, the text/plain part really was empty.
1029 ------=_Part_876302--
1032 if [ $can_reformat_texthtml -eq 1 ]; then
1033 #### lynx inserts multiple blank lines, so squeeze them.
1034 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1035 squeeze_lines
> "$actual"
1036 check
"$expected" "$actual" 'ignore space'
1042 # check -noreplacetextplain
1043 cat >"$expected" <<EOF
1044 To: recipient@example.com
1045 From: sender@example.com
1046 Subject: mhfixmsg replacement of bad text/plain part test
1048 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1051 Content-Type: text/plain; charset="iso-8859-15"
1052 Content-Transfer-Encoding: 7bit
1053 Content-Disposition: inline
1058 Content-Type: text/html; charset="UTF-8"
1059 Content-Transfer-Encoding: 8bit
1060 Content-Disposition: inline
1063 <title>eticket</title>
1066 Yes, the text/plain part really was empty.
1070 ------=_Part_876302--
1073 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1074 check
"$expected" "$actual"
1078 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1081 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1082 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1083 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1085 run_test
'mhfixmsg 15' ''
1086 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1087 "${MH_TEST_DIR}/Mail/inbox/15.original"
1091 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1093 run_test
'mhfixmsg 19 -normmproc'
1094 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1095 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1099 run_test
'mhfixmsg 20 -rmmproc true'
1100 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1101 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1102 failed
=`expr ${failed:-0} + 1`
1106 # make sure there are no tmp files left over
1107 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1109 cat >"$expected" <<EOF
1112 check
"$expected" "$actual"