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 .
"${MH_OBJ_DIR}/test/common.sh"
19 #### Make sure that html-to-text conversion is what we expect.
20 require_locale en_US.utf
-8 en_US.utf8
21 LC_ALL
=en_US.UTF
-8; export LC_ALL
23 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
24 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
25 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
26 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
28 if grep mhfixmsg
-format-text/html
"${MH_TEST_DIR}/Mail/mhn.defaults" \
30 can_reformat_texthtml
=1
31 if grep 'mhfixmsg-format-text/html.*w3m' "${MH_TEST_DIR}/Mail/mhn.defaults" \
33 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
34 #### support testing with non-writeable $HOME, and to not leave
35 #### relics from this test if it is writeable but doesn't already
36 #### have a .w3m, and to not depend on whatever is in that if it
37 #### does already exist, overwrite $HOME if using w3m.
38 HOME
="$MHTMPDIR"; export HOME
41 echo "$0: skipping -reformat check because no text browser was found"
42 can_reformat_texthtml
=0
47 cat >"$expected" <<EOF
48 Usage: mhfixmsg [+folder] [msgs] [switches]
68 run_prog mhfixmsg
-help >"$actual" 2>&1
69 check
"$expected" "$actual"
73 case `mhfixmsg -version` in
75 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
76 failed
=`expr ${failed:-0} + 1`;;
80 # check that non-MIME messages aren't modified
82 run_test
'mhfixmsg first -outfile '"$actual" ''
83 check
"`mhpath first`" "$actual" 'keep first'
86 # check that non-MIME messages with no bodies aren't modified
88 cat >`mhpath new` <<EOF
89 From: Test <test@example.com>
90 To: Some User <user@example.com>
91 Date: Fri, 29 Sep 2006 00:00:00
93 Subject: message with no body
96 run_test
'mhfixmsg last -outfile '"$actual" ''
97 check
"`mhpath last`" "$actual"
101 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
104 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
105 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
107 Content-Type: MULTIPART/MIXED;
108 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
109 Content-Transfer-Encoding: QUOTED-PRINTABLE
111 This message is in MIME format. The first part should be readable
113 while the remaining parts are likely unreadable without MIME-aware
116 ------=_NextPart_000_0000_00000000.00000000
117 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
118 Content-Transfer-Encoding: 8BIT
120 Some text in swedish.
122 Varf=C3=B6r inte anv=C3=A4nda...
124 ------=_NextPart_000_0000_00000000.00000000--
126 And some text after the last part.
129 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
131 run_test
'mhfixmsg last -nofixcte' ''
132 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
135 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
137 cat >"$expected" <<EOF
140 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
141 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
143 Content-Type: MULTIPART/MIXED;
144 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
145 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
146 Content-Transfer-Encoding: 8bit
148 This message is in MIME format. The first part should be readable
150 while the remaining parts are likely unreadable without MIME-aware
153 ------=_NextPart_000_0000_00000000.00000000
154 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
155 Content-Transfer-Encoding: 8BIT
157 Some text in swedish.
159 Varf=C3=B6r inte anv=C3=A4nda...
161 ------=_NextPart_000_0000_00000000.00000000--
163 And some text after the last part.
166 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
167 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
168 QUOTED-PRINTABLE with 8 bit"
169 check
"$expected" "$actual" 'keep first'
172 # check with no options: checks backup
173 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
174 folder last
>/dev
/null
175 run_test
'mhfixmsg' ''
176 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
177 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
178 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
181 # check backup with -file
182 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
183 folder last
>/dev
/null
184 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
185 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
186 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
189 # check -reformat (enabled by default): addition of text/plain part
190 # to solitary text/html part
192 prepare_space
>"$expected" <<EOF
194 From: sender@example.com
195 To: bonquiqui@example.com
197 Date: Sat, 26 Jan 2013 17:37:53 -0500
198 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
200 ------=_nmh-multipart
201 Content-Type: text/plain; charset="Windows-1252"
202 Content-Transfer-Encoding: 8bit
204 Need to go! Need ... to ... go!
206 ------=_nmh-multipart
207 Content-Type: text/html; charset="Windows-1252"
208 Content-Transfer-Encoding: 8bit
212 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
213 <meta name="Generator" content="Microsoft Exchange Server">
214 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
218 <div>Need to go! Need ... to ... go!</div>
222 ------=_nmh-multipart--
225 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
227 From: sender@example.com
228 To: bonquiqui@example.com
230 Date: Sat, 26 Jan 2013 17:37:53 -0500
231 Content-Type: text/html; charset="Windows-1252"
232 Content-Transfer-Encoding: quoted-printable
236 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
238 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
239 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
240 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
244 <div>Need to go! Need ... to ... go!</div>
249 if [ $can_reformat_texthtml -eq 1 ]; then
250 printf '%s\n' "mhfixmsg: 12, insert text/plain part
251 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
254 #### lynx inserts multiple blank lines, so squeeze them.
255 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
256 squeeze_lines
>"$actual"
257 check
"$expected" "$actual" 'ignore space'
258 check
"$expected.err" "$actual.err"
264 # check implicit -file with absolute pathname
265 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
268 # check handling of boundary string that appears in message body
270 prepare_space
>"$expected" <<EOF
272 From: sender@example.com
273 To: bonquiqui@example.com
275 Date: Sat, 26 Jan 2013 17:37:53 -0500
276 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
278 ------=_nmh-multipart-3
279 Content-Type: text/plain; charset="Windows-1252"
280 Content-Transfer-Encoding: 8bit
282 ------=_nmh-multipart
283 ------=_nmh-multipart-1
284 ------=_nmh-multipart-2
286 ------=_nmh-multipart-3
287 Content-Type: text/html; charset="Windows-1252"
288 Content-Transfer-Encoding: 8bit
292 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
293 <meta name="Generator" content="Microsoft Exchange Server">
294 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
297 ------=_nmh-multipart<br>
298 ------=_nmh-multipart-1<br>
299 ------=_nmh-multipart-2<br>
303 ------=_nmh-multipart-3--
306 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
308 From: sender@example.com
309 To: bonquiqui@example.com
311 Date: Sat, 26 Jan 2013 17:37:53 -0500
312 Content-Type: text/html; charset="Windows-1252"
313 Content-Transfer-Encoding: quoted-printable
317 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
319 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
320 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
321 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
324 ------=3D_nmh-multipart<br>
325 ------=3D_nmh-multipart-1<br>
326 ------=3D_nmh-multipart-2<br>
331 if [ $can_reformat_texthtml -eq 1 ]; then
332 printf '%s\n' "mhfixmsg: 12, insert text/plain part
333 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
336 #### lynx inserts multiple blank lines, so squeeze them.
337 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
338 squeeze_lines
>"$actual"
339 check
"$expected" "$actual" 'ignore space'
340 check
"$expected.err" "$actual.err"
347 prepare_space
>"$expected" <<EOF
349 From: sender@example.com
350 To: bonquiqui@example.com
352 Date: Sat, 26 Jan 2013 17:37:53 -0500
353 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
355 ------=_nmh-multipart
356 Content-Type: text/plain; charset="Windows-1252"
357 Content-Transfer-Encoding: 8bit
359 Need to go! Need ... to ... go!
361 ------=_nmh-multipart
362 Content-Type: text/html; charset="Windows-1252"
363 Content-Transfer-Encoding: quoted-printable
367 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
369 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
370 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
371 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
375 <div>Need to go! Need ... to ... go!</div>
379 ------=_nmh-multipart--
382 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
384 From: sender@example.com
385 To: bonquiqui@example.com
387 Date: Sat, 26 Jan 2013 17:37:53 -0500
388 Content-Type: text/html; charset="Windows-1252"
389 Content-Transfer-Encoding: quoted-printable
393 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
395 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
396 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
397 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
401 <div>Need to go! Need ... to ... go!</div>
406 if [ $can_reformat_texthtml -eq 1 ]; then
407 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
409 #### lynx inserts multiple blank lines, so squeeze them.
410 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
411 squeeze_lines
>"$actual"
412 check
"$expected" "$actual" 'ignore space'
413 check
"$expected.err" "$actual.err"
419 # check -decode (enabled by default)
420 cat >"$expected" <<EOF
421 To: recipient@example.com
422 From: sender@example.com
423 Subject: mhfixmsg decode test
425 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
427 ------- =_aaaaaaaaaa0
428 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
429 Content-Disposition: attachment; filename="test4.txt"
430 Content-Transfer-Encoding: 8bit
432 This is a text/plain part.
434 ------- =_aaaaaaaaaa0--
437 cat >`mhpath new` <<EOF
438 To: recipient@example.com
439 From: sender@example.com
440 Subject: mhfixmsg decode test
442 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
444 ------- =_aaaaaaaaaa0
445 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
446 Content-Disposition: attachment; filename="test4.txt"
447 Content-Transfer-Encoding: base64
449 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
451 ------- =_aaaaaaaaaa0--
454 run_prog mhfixmsg last
-outfile "$actual"
455 check
"$expected" "$actual"
458 # check -decode with more complicated content structure
460 To: recipient@example.com
461 From: sender@example.com
462 Subject: mhfixmsg decode test 2
464 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
466 This is additional content before the first subpart of the multipart.
468 ------- =_aaaaaaaaaa0
469 Content-Type: multipart/related;
470 type="text/plain"; boundary="subpart__1.1"
473 Content-Type: text/plain; charset="iso-8859-1"
474 Content-Disposition: attachment; filename="test1.txt"
476 This is the first text/plain part, in a subpart.
480 This is additional content after the last subpart of the multipart.
482 ------- =_aaaaaaaaaa0
483 Content-Type: text/plain; charset="iso-8859-1"
484 Content-Disposition: attachment; filename="test2.txt"
485 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
486 Content-Transfer-Encoding: 8bit
488 This is the second text/plain part.
490 ------- =_aaaaaaaaaa0
491 Content-Type: text/plain; charset="iso-8859-1"
492 Content-Disposition: attachment; filename="test3.txt"
494 This is the third text/plain part.
496 ------- =_aaaaaaaaaa0
497 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
498 Content-Disposition: attachment; filename="test4.txt"
499 Content-Transfer-Encoding: 8bit
501 This is the fourth text/plain part.
503 ------- =_aaaaaaaaaa0--
505 This is additional content after the last subpart of the multipart.
508 cat >`mhpath new` <<EOF
509 To: recipient@example.com
510 From: sender@example.com
511 Subject: mhfixmsg decode test 2
513 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
515 This is additional content before the first subpart of the multipart.
517 ------- =_aaaaaaaaaa0
518 Content-Type: multipart/related;
519 type="text/plain"; boundary="subpart__1.1"
522 Content-Type: text/plain; charset="iso-8859-1"
523 Content-Disposition: attachment; filename="test1.txt"
525 This is the first text/plain part, in a subpart.
529 This is additional content after the last subpart of the multipart.
531 ------- =_aaaaaaaaaa0
532 Content-Type: text/plain; charset="iso-8859-1"
533 Content-Disposition: attachment; filename="test2.txt"
534 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
535 Content-Transfer-Encoding: quoted-printable
537 This is the second text/plain part.
539 ------- =_aaaaaaaaaa0
540 Content-Type: text/plain; charset="iso-8859-1"
541 Content-Disposition: attachment; filename="test3.txt"
543 This is the third text/plain part.
545 ------- =_aaaaaaaaaa0
546 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
547 Content-Disposition: attachment; filename="test4.txt"
548 Content-Transfer-Encoding: base64
550 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
552 ------- =_aaaaaaaaaa0--
554 This is additional content after the last subpart of the multipart.
556 run_prog mhfixmsg last
-outfile "$actual"
557 check
"$expected" "$actual"
560 # check attempted -decode of binary text
561 #### Generated the encoded text below with:
562 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
563 cat >`mhpath new` <<EOF
564 To: recipient@example.com
565 From: sender@example.com
566 Subject: mhfixmsg attempted binary decode test
568 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
570 ------- =_aaaaaaaaaa0
571 Content-Type: text/plain; charset="iso-8859-1"; name="nul+square.txt"
572 Content-Transfer-Encoding: base64
576 ------- =_aaaaaaaaaa0--
579 cp -p `mhpath last` "$expected"
580 run_prog mhfixmsg last
581 check
`mhpath last` "$expected" 'keep first'
584 # check -decode of binary text
585 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
586 From: sender@example.com
587 Subject: mhfixmsg binary decode test
589 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
591 ------- =_aaaaaaaaaa0
592 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"nul+square.txt\"
593 Content-Transfer-Encoding: binary
597 ------- =_aaaaaaaaaa0--
599 ## output_content() in mhoutsbr.c can't handle binary content.
600 ## mhfixmsg last -decodetext binary -outfile "$actual"
601 ## check "$expected" "$actual"
606 # check that -reformat succeeds when decode of binary text fails
607 prepare_space
>"$expected" <<'EOF'
609 Date: Thu, 11 Apr 2013 02:47:08 -0700
611 From: <sender@example.com>
612 Subject: body requires binary encoding
613 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
615 ------=_nmh-multipart
616 Content-Type: text/plain; charset="ISO-8859-1"
617 Content-Transfer-Encoding: 8bit
622 Vehicle License Fee $1.84
625 ------=_nmh-multipart
626 Content-Type: text/html; charset="ISO-8859-1"
627 Content-Transfer-Encoding: quoted-printable
632 cat >`mhpath new` <<'EOF'
634 Content-Type: text/html; charset="ISO-8859-1"
635 Content-Transfer-Encoding: quoted-printable
636 Date: Thu, 11 Apr 2013 02:47:08 -0700
638 From: <sender@example.com>
639 Subject: body requires binary encoding
642 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
643 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
644 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
645 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
646 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
647 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
648 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
649 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
650 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
651 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
652 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
653 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
654 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
655 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
656 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
657 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
658 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
659 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
660 #333333" size=3D"2">$6.00</font></td></tr>
666 if [ $can_reformat_texthtml -eq 1 ]; then
667 #### lynx inserts multiple blank lines, so squeeze them.
668 #### Truncate to avoid comparing the html portion because it can
669 #### get reformatted.
670 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
671 check
"$expected" "$actual" 'ignore space'
673 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
679 # Also checks preservation of attributes after one (charset) that is
681 cat >"$expected" <<EOF
682 To: recipient@example.com
683 From: sender@example.com
684 Subject: mhfixmsg textcharset test
686 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
688 ------- =_aaaaaaaaaa0
689 Content-Type: text/plain; charset="utf-8"; name="square.txt"
690 Content-Disposition: attachment; filename="square.txt"
691 Content-Transfer-Encoding: 8bit
695 ------- =_aaaaaaaaaa0--
698 #### Generated the encoded text below with:
699 #### $ printf '\xbd\xb2=\xbc\n' | base64
700 cat >`mhpath new` <<EOF
701 To: recipient@example.com
702 From: sender@example.com
703 Subject: mhfixmsg textcharset test
705 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
707 ------- =_aaaaaaaaaa0
708 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
709 Content-Disposition: attachment; filename="square.txt"
710 Content-Transfer-Encoding: base64
714 ------- =_aaaaaaaaaa0--
717 if test "$ICONV_ENABLED" -eq 1; then
718 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
719 check
"$expected" "$actual"
721 echo "$0: skipping -textcharset check because nmh was built without iconv"
726 # check -nofixboundary
727 cat >"$expected" <<EOF
730 cat >`mhpath new` <<EOF
731 Date: Fri, 13 May 2011 08:21:12 -0500
732 Content-Type: multipart/alternative;
733 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
734 Content-Transfer-Encoding: 8bit
736 From: <sender@example.com>
737 To: <recipient@example.com>
738 Subject: mhfixmsg bad boundary test
740 This is a multi-part message in MIME format.
742 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
743 Content-Type: text/plain
745 The boundaries of this part don't match the header boundary.
747 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
750 cp -p `mhpath last` `mhpath new`
752 run_test
'mhfixmsg last -nofixboundary' ''
753 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
756 # check that message is not output when fed through stdin
757 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
758 check
"$expected" "$actual"
759 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
760 "$actual.err" >/dev
/null
; then
763 echo "$0: test failed, output is in $actual.err."
764 failed
=`expr ${failed:-0} + 1`
768 # check fixup of erroneous boundary in multipart (-fixboundary,
769 # enabled by default)
771 cat >"$expected" <<EOF
772 Date: Fri, 13 May 2011 08:21:12 -0500
773 Content-Type: multipart/alternative;
774 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
775 Content-Transfer-Encoding: 8bit
777 From: <sender@example.com>
778 To: <recipient@example.com>
779 Subject: mhfixmsg bad boundary test
781 This is a multi-part message in MIME format.
783 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
784 Content-Type: text/plain
786 The boundaries of this part don't match the header boundary.
788 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
791 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
792 "mhfixmsg: 17, fix multipart boundary"
793 check
"$expected" "$actual"
796 # check that text/plain part is not added to text/html in multipart/related
797 # when it shouldn't be
798 cat >`mhpath new` <<EOF
800 Date: Tue, 26 Feb 2013 18:07:20 -0600
801 Subject: multipart/related, not /alternative
802 Content-Type: multipart/related;
803 type="text/html"; boundary="----=_Part_90310_101292502.1"
805 ------=_Part_90310_101292502.1
806 Content-Type: text/html; charset="us-ascii"
807 Content-Transfer-Encoding: 7bit
810 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
811 <title>HTML Content</title>
814 This is the real content.
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 cp -p `mhpath last` "$expected"
829 if [ $can_reformat_texthtml -eq 1 ]; then
830 #### lynx inserts multiple blank lines, so squeeze them.
831 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
832 check
"$expected" "$actual" 'ignore space'
838 # check handling of rfc822 message type
839 cat >"$expected" <<EOF
840 From: Test <test@example.com>
841 To: Some User <user@example.com>
842 Date: Fri, 29 Sep 2006 00:00:00
843 Message-Id: @test.nmh
844 Subject: message with message/rfc822 attachment
846 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
848 and some garbage before the attachment
850 ------- =_aaaaaaaaaa0
851 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
852 Content-Description: 1552
853 Content-Disposition: attachment; filename="1552"
855 From: Test <test@example.com>
856 To: <another_user@example.com>
857 Date: Thu, 28 Sep 2006 00:00:00
858 Message-Id: @test.nmh
859 Subject: message/rfc822 attachment
861 This is an RFC-822 message.
863 ------- =_aaaaaaaaaa0--
865 and some garbage at the end
868 cat >`mhpath new` <<EOF
869 From: Test <test@example.com>
870 To: Some User <user@example.com>
871 Date: Fri, 29 Sep 2006 00:00:00
872 Message-Id: @test.nmh
873 Subject: message with message/rfc822 attachment
875 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
877 and some garbage before the attachment
879 ------- =_aaaaaaaaaa0
880 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
881 Content-Description: 1552
882 Content-Disposition: attachment; filename="1552"
884 From: Test <test@example.com>
885 To: <another_user@example.com>
886 Date: Thu, 28 Sep 2006 00:00:00
887 Message-Id: @test.nmh
888 Subject: message/rfc822 attachment
890 This is an RFC-822 message.
892 ------- =_aaaaaaaaaa0--
894 and some garbage at the end
897 run_test
'mhfixmsg last -outfile '"$actual" ''
898 check
"$expected" "$actual"
901 # check stripping of CRs from ASCII text context
902 cat >"$expected" <<EOF
904 From: sender@example.com
905 To: recipient@example.com
906 Subject: message with CR's
907 Date: Mon, 29 Apr 2013 11:51:45 -0400
909 There are two CR-LF pairs at the end of this sentence.
913 cat >`mhpath new` <<'EOF'
915 From: sender@example.com
916 To: recipient@example.com
917 Subject: message with CR's
918 Date: Mon, 29 Apr 2013 11:51:45 -0400
920 There are two CR-LF pairs at the end of this sentence.
924 run_prog mhfixmsg last
-outfile "$actual"
925 check
"$expected" "$actual"
928 # check -replacetextplain
929 prepare_space
>"$expected" <<EOF
930 To: recipient@example.com
931 From: sender@example.com
932 Subject: mhfixmsg replacement of bad text/plain part test
934 Content-Type: multipart/alternative; boundary="----=_Part_876302"
937 Content-Type: text/plain; charset="UTF-8"
938 Content-Transfer-Encoding: 8bit
940 Yes, the text/plain part really was empty.
943 Content-Type: text/html; charset="UTF-8"
944 Content-Transfer-Encoding: 8bit
945 Content-Disposition: inline
948 <title>eticket</title>
951 Yes, the text/plain part really was empty.
955 ------=_Part_876302--
958 cat >`mhpath new` <<'EOF'
959 To: recipient@example.com
960 From: sender@example.com
961 Subject: mhfixmsg replacement of bad text/plain part test
963 Content-Type: multipart/alternative; boundary="----=_Part_876302"
966 Content-Type: text/plain; charset="iso-8859-15"
967 Content-Transfer-Encoding: 7bit
968 Content-Disposition: inline
973 Content-Type: text/html; charset="UTF-8"
974 Content-Transfer-Encoding: 8bit
975 Content-Disposition: inline
978 <title>eticket</title>
981 Yes, the text/plain part really was empty.
985 ------=_Part_876302--
988 if [ $can_reformat_texthtml -eq 1 ]; then
989 #### lynx inserts multiple blank lines, so squeeze them.
990 run_prog mhfixmsg last
-replacetextplain -outfile - | \
991 squeeze_lines
> "$actual"
992 check
"$expected" "$actual" 'ignore space'
998 # check -noreplacetextplain
999 cat >"$expected" <<EOF
1000 To: recipient@example.com
1001 From: sender@example.com
1002 Subject: mhfixmsg replacement of bad text/plain part test
1004 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1007 Content-Type: text/plain; charset="iso-8859-15"
1008 Content-Transfer-Encoding: 7bit
1009 Content-Disposition: inline
1014 Content-Type: text/html; charset="UTF-8"
1015 Content-Transfer-Encoding: 8bit
1016 Content-Disposition: inline
1019 <title>eticket</title>
1022 Yes, the text/plain part really was empty.
1026 ------=_Part_876302--
1029 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1030 check
"$expected" "$actual"
1033 # check removal of extraneous trailing semicolon from header parameter list
1034 cat >"$expected" <<EOF
1035 To: recipient@example.com
1037 From: sender@example.com
1039 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1041 ------- =_aaaaaaaaaa0
1042 Content-Type: text/plain; charset="us-ascii"
1046 ------- =_aaaaaaaaaa0
1047 Content-Type: text/plain; charset="us-ascii";
1049 Content-Description: check folded headers, with and without trailing semicolon
1050 Content-Disposition: attachment;
1055 ------- =_aaaaaaaaaa0--
1058 cat >`mhpath new` <<EOF
1059 To: recipient@example.com
1061 From: sender@example.com
1063 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1065 ------- =_aaaaaaaaaa0
1066 Content-Type: text/plain; charset="us-ascii";
1070 ------- =_aaaaaaaaaa0
1071 Content-Type: text/plain; charset="us-ascii";
1073 Content-Description: check folded headers, with and without trailing semicolon
1074 Content-Disposition: attachment;
1079 ------- =_aaaaaaaaaa0--
1081 run_test
'mhfixmsg last -outfile '"$actual" ''
1082 check
"$expected" "$actual"
1086 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1089 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1090 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1091 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1093 run_test
'mhfixmsg 15' ''
1094 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1095 "${MH_TEST_DIR}/Mail/inbox/15.original"
1099 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1101 run_test
'mhfixmsg 19 -normmproc'
1102 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1103 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1107 run_test
'mhfixmsg 20 -rmmproc true'
1108 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1109 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1110 failed
=`expr ${failed:-0} + 1`
1115 cat >"$expected" <<EOF
1116 To: recipient@example.com
1117 From: sender@example.com
1118 Subject: mhfixmsg with incorrect Content-Type
1120 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1122 ------- =_aaaaaaaaaa0
1123 Content-Type: text/plain; name="plaintext.txt"
1127 ------- =_aaaaaaaaaa0--
1130 cat >`mhpath new` <<EOF
1131 To: recipient@example.com
1132 From: sender@example.com
1133 Subject: mhfixmsg with incorrect Content-Type
1135 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1137 ------- =_aaaaaaaaaa0
1138 Content-Type: application/octet-stream; name="plaintext.txt"
1142 ------- =_aaaaaaaaaa0--
1145 mhfixmsg
-fixtype application
/octet
-stream last
1146 check
"$expected" `mhpath last`
1149 # make sure there are no tmp files left over
1150 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1152 cat >"$expected" <<EOF
1155 check
"$expected" "$actual"