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 #### Make sure that html-to-text conversion is what we expect.
18 require_locale en_US.utf
-8 en_US.utf8
19 LC_ALL
=en_US.UTF
-8; export LC_ALL
21 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
22 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
23 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
24 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
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.
36 HOME
="$MHTMPDIR"; export HOME
39 echo "$0: skipping -reformat check because no text browser was found"
40 can_reformat_texthtml
=0
45 # Verified behavior consistent with compiled sendmail.
46 cat >"$expected" <<EOF
47 Usage: mhfixmsg [+folder] [msgs] [switches]
65 run_prog 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 prepare_space
>"$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 squeeze them.
253 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
254 squeeze_lines
>"$actual"
255 check
"$expected" "$actual" 'ignore space'
256 check
"$expected.err" "$actual.err"
262 # check implicit -file with absolute pathname
263 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
266 # check handling of boundary string that appears in message body
268 prepare_space
>"$expected" <<EOF
270 From: sender@example.com
271 To: bonquiqui@example.com
273 Date: Sat, 26 Jan 2013 17:37:53 -0500
274 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
276 ------=_nmh-multipart-3
277 Content-Type: text/plain; charset="Windows-1252"
278 Content-Transfer-Encoding: 8bit
280 ------=_nmh-multipart
281 ------=_nmh-multipart-1
282 ------=_nmh-multipart-2
284 ------=_nmh-multipart-3
285 Content-Type: text/html; charset="Windows-1252"
286 Content-Transfer-Encoding: 8bit
290 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
291 <meta name="Generator" content="Microsoft Exchange Server">
292 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
295 ------=_nmh-multipart<br>
296 ------=_nmh-multipart-1<br>
297 ------=_nmh-multipart-2<br>
301 ------=_nmh-multipart-3--
304 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
306 From: sender@example.com
307 To: bonquiqui@example.com
309 Date: Sat, 26 Jan 2013 17:37:53 -0500
310 Content-Type: text/html; charset="Windows-1252"
311 Content-Transfer-Encoding: quoted-printable
315 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
317 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
318 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
319 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
322 ------=3D_nmh-multipart<br>
323 ------=3D_nmh-multipart-1<br>
324 ------=3D_nmh-multipart-2<br>
329 if [ $can_reformat_texthtml -eq 1 ]; then
330 printf '%s\n' "mhfixmsg: 12, insert text/plain part
331 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
334 #### lynx inserts multiple blank lines, so squeeze them.
335 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
336 squeeze_lines
>"$actual"
337 check
"$expected" "$actual" 'ignore space'
338 check
"$expected.err" "$actual.err"
345 prepare_space
>"$expected" <<EOF
347 From: sender@example.com
348 To: bonquiqui@example.com
350 Date: Sat, 26 Jan 2013 17:37:53 -0500
351 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
353 ------=_nmh-multipart
354 Content-Type: text/plain; charset="Windows-1252"
355 Content-Transfer-Encoding: 8bit
357 Need to go! Need ... to ... go!
359 ------=_nmh-multipart
360 Content-Type: text/html; charset="Windows-1252"
361 Content-Transfer-Encoding: quoted-printable
365 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
367 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
368 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
369 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
373 <div>Need to go! Need ... to ... go!</div>
377 ------=_nmh-multipart--
380 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
382 From: sender@example.com
383 To: bonquiqui@example.com
385 Date: Sat, 26 Jan 2013 17:37:53 -0500
386 Content-Type: text/html; charset="Windows-1252"
387 Content-Transfer-Encoding: quoted-printable
391 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
393 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
394 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
395 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
399 <div>Need to go! Need ... to ... go!</div>
404 if [ $can_reformat_texthtml -eq 1 ]; then
405 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
407 #### lynx inserts multiple blank lines, so squeeze them.
408 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
409 squeeze_lines
>"$actual"
410 check
"$expected" "$actual" 'ignore space'
411 check
"$expected.err" "$actual.err"
417 # check -decode (enabled by default)
418 cat >"$expected" <<EOF
419 To: recipient@example.com
420 From: sender@example.com
421 Subject: mhfixmsg decode test
423 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
425 ------- =_aaaaaaaaaa0
426 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
427 Content-Disposition: attachment; filename="test4.txt"
428 Content-Transfer-Encoding: 8bit
430 This is a text/plain part.
432 ------- =_aaaaaaaaaa0--
435 cat >`mhpath new` <<EOF
436 To: recipient@example.com
437 From: sender@example.com
438 Subject: mhfixmsg decode test
440 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
442 ------- =_aaaaaaaaaa0
443 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
444 Content-Disposition: attachment; filename="test4.txt"
445 Content-Transfer-Encoding: base64
447 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
449 ------- =_aaaaaaaaaa0--
452 run_prog mhfixmsg last
-outfile "$actual"
453 check
"$expected" "$actual"
456 # check -decode with more complicated content structure
458 To: recipient@example.com
459 From: sender@example.com
460 Subject: mhfixmsg decode test 2
462 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
464 This is additional content before the first subpart of the multipart.
466 ------- =_aaaaaaaaaa0
467 Content-Type: multipart/related;
468 type="multipart/alternative";
469 boundary="subpart__1.1"
472 Content-Type: text/plain; charset="iso-8859-1"
473 Content-Disposition: attachment; filename="test1.txt"
475 This is the first text/plain part, in a subpart.
479 This is additional content after the last subpart of the multipart.
481 ------- =_aaaaaaaaaa0
482 Content-Type: text/plain; charset="iso-8859-1"
483 Content-Disposition: attachment; filename="test2.txt"
484 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
485 Content-Transfer-Encoding: 8bit
487 This is the second text/plain part.
489 ------- =_aaaaaaaaaa0
490 Content-Type: text/plain; charset="iso-8859-1"
491 Content-Disposition: attachment; filename="test3.txt"
493 This is the third text/plain part.
495 ------- =_aaaaaaaaaa0
496 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
497 Content-Disposition: attachment; filename="test4.txt"
498 Content-Transfer-Encoding: 8bit
500 This is the fourth text/plain part.
502 ------- =_aaaaaaaaaa0--
504 This is additional content after the last subpart of the multipart.
507 cat >`mhpath new` <<EOF
508 To: recipient@example.com
509 From: sender@example.com
510 Subject: mhfixmsg decode test 2
512 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
514 This is additional content before the first subpart of the multipart.
516 ------- =_aaaaaaaaaa0
517 Content-Type: multipart/related;
518 type="multipart/alternative";
519 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 added to lone text/html in multipart/related
797 prepare_space
>"$expected" <<EOF
799 Date: Tue, 26 Feb 2013 18:07:20 -0600
800 Subject: multipart/related, not /alternative
801 Content-Type: multipart/related;
802 boundary="----=_Part_90310_101292502.1"
804 ------=_Part_90310_101292502.1
805 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
807 ------=_nmh-multipart1
808 Content-Type: text/plain; charset="us-ascii"
809 Content-Transfer-Encoding: 7bit
811 This is the real content.
813 ------=_nmh-multipart1
814 Content-Type: text/html; charset="us-ascii"
815 Content-Transfer-Encoding: 7bit
818 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
819 <title>HTML Content</title>
822 This is the real content.
826 ------=_nmh-multipart1--
828 ------=_Part_90310_101292502.1
829 Content-Type: text/plain; charset="us-ascii"
830 Content-Transfer-Encoding: 7bit
832 Your email client does not support HTML messages
834 ------=_Part_90310_101292502.1--
837 cat >`mhpath new` <<EOF
839 Date: Tue, 26 Feb 2013 18:07:20 -0600
840 Subject: multipart/related, not /alternative
841 Content-Type: multipart/related;
842 boundary="----=_Part_90310_101292502.1"
844 ------=_Part_90310_101292502.1
845 Content-Type: text/html; charset="us-ascii"
846 Content-Transfer-Encoding: 7bit
849 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
850 <title>HTML Content</title>
853 This is the real content.
856 ------=_Part_90310_101292502.1
857 Content-Type: text/plain; charset="us-ascii"
858 Content-Transfer-Encoding: 7bit
860 Your email client does not support HTML messages
861 ------=_Part_90310_101292502.1--
864 if [ $can_reformat_texthtml -eq 1 ]; then
865 #### lynx inserts multiple blank lines, so squeeze them.
866 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
867 check
"$expected" "$actual" 'ignore space'
873 # check handling of rfc822 message type
874 cat >"$expected" <<EOF
875 From: Test <test@example.com>
876 To: Some User <user@example.com>
877 Date: Fri, 29 Sep 2006 00:00:00
878 Message-Id: @test.nmh
879 Subject: message with message/rfc822 attachment
881 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
883 and some garbage before the attachment
885 ------- =_aaaaaaaaaa0
886 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
887 Content-Description: 1552
888 Content-Disposition: attachment; filename="1552"
890 From: Test <test@example.com>
891 To: <another_user@example.com>
892 Date: Thu, 28 Sep 2006 00:00:00
893 Message-Id: @test.nmh
894 Subject: message/rfc822 attachment
896 This is an RFC-822 message.
898 ------- =_aaaaaaaaaa0--
900 and some garbage at the end
903 cat >`mhpath new` <<EOF
904 From: Test <test@example.com>
905 To: Some User <user@example.com>
906 Date: Fri, 29 Sep 2006 00:00:00
907 Message-Id: @test.nmh
908 Subject: message with message/rfc822 attachment
910 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
912 and some garbage before the attachment
914 ------- =_aaaaaaaaaa0
915 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
916 Content-Description: 1552
917 Content-Disposition: attachment; filename="1552"
919 From: Test <test@example.com>
920 To: <another_user@example.com>
921 Date: Thu, 28 Sep 2006 00:00:00
922 Message-Id: @test.nmh
923 Subject: message/rfc822 attachment
925 This is an RFC-822 message.
927 ------- =_aaaaaaaaaa0--
929 and some garbage at the end
932 run_test
'mhfixmsg last -outfile '"$actual" ''
933 check
"$expected" "$actual"
936 # check stripping of CRs from ASCII text context
937 cat >"$expected" <<EOF
939 From: sender@example.com
940 To: recipient@example.com
941 Subject: message with CR's
942 Date: Mon, 29 Apr 2013 11:51:45 -0400
944 There are two CR-LF pairs at the end of this sentence.
948 cat >`mhpath new` <<'EOF'
950 From: sender@example.com
951 To: recipient@example.com
952 Subject: message with CR's
953 Date: Mon, 29 Apr 2013 11:51:45 -0400
955 There are two CR-LF pairs at the end of this sentence.
959 run_prog mhfixmsg last
-outfile "$actual"
960 check
"$expected" "$actual"
963 # check -replacetextplain
964 prepare_space
>"$expected" <<EOF
965 To: recipient@example.com
966 From: sender@example.com
967 Subject: mhfixmsg replacement of bad text/plain part test
969 Content-Type: multipart/alternative; boundary="----=_Part_876302"
972 Content-Type: text/plain; charset="UTF-8"
973 Content-Transfer-Encoding: 8bit
975 Yes, the text/plain part really was empty.
978 Content-Type: text/html; charset="UTF-8"
979 Content-Transfer-Encoding: 8bit
980 Content-Disposition: inline
983 <title>eticket</title>
986 Yes, the text/plain part really was empty.
990 ------=_Part_876302--
993 cat >`mhpath new` <<'EOF'
994 To: recipient@example.com
995 From: sender@example.com
996 Subject: mhfixmsg replacement of bad text/plain part test
998 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1001 Content-Type: text/plain; charset="iso-8859-15"
1002 Content-Transfer-Encoding: 7bit
1003 Content-Disposition: inline
1008 Content-Type: text/html; charset="UTF-8"
1009 Content-Transfer-Encoding: 8bit
1010 Content-Disposition: inline
1013 <title>eticket</title>
1016 Yes, the text/plain part really was empty.
1020 ------=_Part_876302--
1023 if [ $can_reformat_texthtml -eq 1 ]; then
1024 #### lynx inserts multiple blank lines, so squeeze them.
1025 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1026 squeeze_lines
> "$actual"
1027 check
"$expected" "$actual" 'ignore space'
1033 # check -noreplacetextplain
1034 cat >"$expected" <<EOF
1035 To: recipient@example.com
1036 From: sender@example.com
1037 Subject: mhfixmsg replacement of bad text/plain part test
1039 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1042 Content-Type: text/plain; charset="iso-8859-15"
1043 Content-Transfer-Encoding: 7bit
1044 Content-Disposition: inline
1049 Content-Type: text/html; charset="UTF-8"
1050 Content-Transfer-Encoding: 8bit
1051 Content-Disposition: inline
1054 <title>eticket</title>
1057 Yes, the text/plain part really was empty.
1061 ------=_Part_876302--
1064 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1065 check
"$expected" "$actual"
1069 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1072 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1073 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1074 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1076 run_test
'mhfixmsg 15' ''
1077 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1078 "${MH_TEST_DIR}/Mail/inbox/15.original"
1082 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1084 run_test
'mhfixmsg 19 -normmproc'
1085 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1086 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1090 run_test
'mhfixmsg 20 -rmmproc true'
1091 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1092 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1093 failed
=`expr ${failed:-0} + 1`
1097 # make sure there are no tmp files left over
1098 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1100 cat >"$expected" <<EOF
1103 check
"$expected" "$actual"