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]
66 run_prog mhfixmsg
-help >"$actual" 2>&1
67 check
"$expected" "$actual"
71 # Verified same behavior as compiled mhfixmsg.
72 case `mhfixmsg -version` in
74 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
75 failed
=`expr ${failed:-0} + 1`;;
79 # check that non-MIME messages aren't modified
81 run_test
'mhfixmsg first -outfile '"$actual" ''
82 check
"`mhpath first`" "$actual" 'keep first'
85 # check that non-MIME messages with no bodies aren't modified
87 cat >`mhpath new` <<EOF
88 From: Test <test@example.com>
89 To: Some User <user@example.com>
90 Date: Fri, 29 Sep 2006 00:00:00
92 Subject: message with no body
95 run_test
'mhfixmsg last -outfile '"$actual" ''
96 check
"`mhpath last`" "$actual"
100 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
103 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
104 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
106 Content-Type: MULTIPART/MIXED;
107 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
108 Content-Transfer-Encoding: QUOTED-PRINTABLE
110 This message is in MIME format. The first part should be readable
112 while the remaining parts are likely unreadable without MIME-aware
115 ------=_NextPart_000_0000_00000000.00000000
116 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
117 Content-Transfer-Encoding: 8BIT
119 Some text in swedish.
121 Varf=C3=B6r inte anv=C3=A4nda...
123 ------=_NextPart_000_0000_00000000.00000000--
125 And some text after the last part.
128 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
130 run_test
'mhfixmsg last -nofixcte' ''
131 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
134 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
136 cat >"$expected" <<EOF
139 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
140 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
142 Content-Type: MULTIPART/MIXED;
143 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
144 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
145 Content-Transfer-Encoding: 8bit
147 This message is in MIME format. The first part should be readable
149 while the remaining parts are likely unreadable without MIME-aware
152 ------=_NextPart_000_0000_00000000.00000000
153 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
154 Content-Transfer-Encoding: 8BIT
156 Some text in swedish.
158 Varf=C3=B6r inte anv=C3=A4nda...
160 ------=_NextPart_000_0000_00000000.00000000--
162 And some text after the last part.
165 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
166 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
167 QUOTED-PRINTABLE with 8 bit"
168 check
"$expected" "$actual" 'keep first'
171 # check with no options: checks backup
172 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
173 folder last
>/dev
/null
174 run_test
'mhfixmsg' ''
175 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
176 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
177 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
180 # check backup with -file
181 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
182 folder last
>/dev
/null
183 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
184 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
185 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
188 # check -reformat (enabled by default): addition of text/plain part
189 # to solitary text/html part
191 prepare_space
>"$expected" <<EOF
193 From: sender@example.com
194 To: bonquiqui@example.com
196 Date: Sat, 26 Jan 2013 17:37:53 -0500
197 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
199 ------=_nmh-multipart
200 Content-Type: text/plain; charset="Windows-1252"
201 Content-Transfer-Encoding: 8bit
203 Need to go! Need ... to ... go!
205 ------=_nmh-multipart
206 Content-Type: text/html; charset="Windows-1252"
207 Content-Transfer-Encoding: 8bit
211 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
212 <meta name="Generator" content="Microsoft Exchange Server">
213 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
217 <div>Need to go! Need ... to ... go!</div>
221 ------=_nmh-multipart--
224 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
226 From: sender@example.com
227 To: bonquiqui@example.com
229 Date: Sat, 26 Jan 2013 17:37:53 -0500
230 Content-Type: text/html; charset="Windows-1252"
231 Content-Transfer-Encoding: quoted-printable
235 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
237 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
238 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
239 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
243 <div>Need to go! Need ... to ... go!</div>
248 if [ $can_reformat_texthtml -eq 1 ]; then
249 printf '%s\n' "mhfixmsg: 12, insert text/plain part
250 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
253 #### lynx inserts multiple blank lines, so squeeze them.
254 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
255 squeeze_lines
>"$actual"
256 check
"$expected" "$actual" 'ignore space'
257 check
"$expected.err" "$actual.err"
263 # check implicit -file with absolute pathname
264 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
267 # check handling of boundary string that appears in message body
269 prepare_space
>"$expected" <<EOF
271 From: sender@example.com
272 To: bonquiqui@example.com
274 Date: Sat, 26 Jan 2013 17:37:53 -0500
275 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
277 ------=_nmh-multipart-3
278 Content-Type: text/plain; charset="Windows-1252"
279 Content-Transfer-Encoding: 8bit
281 ------=_nmh-multipart
282 ------=_nmh-multipart-1
283 ------=_nmh-multipart-2
285 ------=_nmh-multipart-3
286 Content-Type: text/html; charset="Windows-1252"
287 Content-Transfer-Encoding: 8bit
291 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
292 <meta name="Generator" content="Microsoft Exchange Server">
293 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
296 ------=_nmh-multipart<br>
297 ------=_nmh-multipart-1<br>
298 ------=_nmh-multipart-2<br>
302 ------=_nmh-multipart-3--
305 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
307 From: sender@example.com
308 To: bonquiqui@example.com
310 Date: Sat, 26 Jan 2013 17:37:53 -0500
311 Content-Type: text/html; charset="Windows-1252"
312 Content-Transfer-Encoding: quoted-printable
316 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
318 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
319 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
320 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
323 ------=3D_nmh-multipart<br>
324 ------=3D_nmh-multipart-1<br>
325 ------=3D_nmh-multipart-2<br>
330 if [ $can_reformat_texthtml -eq 1 ]; then
331 printf '%s\n' "mhfixmsg: 12, insert text/plain part
332 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
335 #### lynx inserts multiple blank lines, so squeeze them.
336 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
337 squeeze_lines
>"$actual"
338 check
"$expected" "$actual" 'ignore space'
339 check
"$expected.err" "$actual.err"
346 prepare_space
>"$expected" <<EOF
348 From: sender@example.com
349 To: bonquiqui@example.com
351 Date: Sat, 26 Jan 2013 17:37:53 -0500
352 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
354 ------=_nmh-multipart
355 Content-Type: text/plain; charset="Windows-1252"
356 Content-Transfer-Encoding: 8bit
358 Need to go! Need ... to ... go!
360 ------=_nmh-multipart
361 Content-Type: text/html; charset="Windows-1252"
362 Content-Transfer-Encoding: quoted-printable
366 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
368 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
369 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
370 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
374 <div>Need to go! Need ... to ... go!</div>
378 ------=_nmh-multipart--
381 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
383 From: sender@example.com
384 To: bonquiqui@example.com
386 Date: Sat, 26 Jan 2013 17:37:53 -0500
387 Content-Type: text/html; charset="Windows-1252"
388 Content-Transfer-Encoding: quoted-printable
392 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
394 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
395 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
396 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
400 <div>Need to go! Need ... to ... go!</div>
405 if [ $can_reformat_texthtml -eq 1 ]; then
406 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
408 #### lynx inserts multiple blank lines, so squeeze them.
409 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
410 squeeze_lines
>"$actual"
411 check
"$expected" "$actual" 'ignore space'
412 check
"$expected.err" "$actual.err"
418 # check -decode (enabled by default)
419 cat >"$expected" <<EOF
420 To: recipient@example.com
421 From: sender@example.com
422 Subject: mhfixmsg decode test
424 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
426 ------- =_aaaaaaaaaa0
427 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
428 Content-Disposition: attachment; filename="test4.txt"
429 Content-Transfer-Encoding: 8bit
431 This is a text/plain part.
433 ------- =_aaaaaaaaaa0--
436 cat >`mhpath new` <<EOF
437 To: recipient@example.com
438 From: sender@example.com
439 Subject: mhfixmsg decode test
441 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
443 ------- =_aaaaaaaaaa0
444 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
445 Content-Disposition: attachment; filename="test4.txt"
446 Content-Transfer-Encoding: base64
448 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
450 ------- =_aaaaaaaaaa0--
453 run_prog mhfixmsg last
-outfile "$actual"
454 check
"$expected" "$actual"
457 # check -decode with more complicated content structure
459 To: recipient@example.com
460 From: sender@example.com
461 Subject: mhfixmsg decode test 2
463 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
465 This is additional content before the first subpart of the multipart.
467 ------- =_aaaaaaaaaa0
468 Content-Type: multipart/related;
469 type="text/plain"; 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="text/plain"; boundary="subpart__1.1"
521 Content-Type: text/plain; charset="iso-8859-1"
522 Content-Disposition: attachment; filename="test1.txt"
524 This is the first text/plain part, in a subpart.
528 This is additional content after the last subpart of the multipart.
530 ------- =_aaaaaaaaaa0
531 Content-Type: text/plain; charset="iso-8859-1"
532 Content-Disposition: attachment; filename="test2.txt"
533 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
534 Content-Transfer-Encoding: quoted-printable
536 This is the second text/plain part.
538 ------- =_aaaaaaaaaa0
539 Content-Type: text/plain; charset="iso-8859-1"
540 Content-Disposition: attachment; filename="test3.txt"
542 This is the third text/plain part.
544 ------- =_aaaaaaaaaa0
545 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
546 Content-Disposition: attachment; filename="test4.txt"
547 Content-Transfer-Encoding: base64
549 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
551 ------- =_aaaaaaaaaa0--
553 This is additional content after the last subpart of the multipart.
555 run_prog mhfixmsg last
-outfile "$actual"
556 check
"$expected" "$actual"
559 # check attempted -decode of binary text
560 #### Generated the encoded text below with:
561 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
562 cat >`mhpath new` <<EOF
563 To: recipient@example.com
564 From: sender@example.com
565 Subject: mhfixmsg attempted binary decode test
567 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
569 ------- =_aaaaaaaaaa0
570 Content-Type: text/plain; charset="iso-8859-1"; name="nul+square.txt"
571 Content-Transfer-Encoding: base64
575 ------- =_aaaaaaaaaa0--
578 cp -p `mhpath last` "$expected"
579 run_prog mhfixmsg last
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=\"nul+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 prepare_space
>"$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 squeeze them.
667 #### Truncate to avoid comparing the html portion because it can
668 #### get reformatted.
669 run_prog mhfixmsg last
-outfile - | squeeze_lines
| 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 textcharset 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 textcharset 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--
716 if test "$ICONV_ENABLED" -eq 1; then
717 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
718 check
"$expected" "$actual"
720 echo "$0: skipping -textcharset check because nmh was built without iconv"
725 # check -nofixboundary
726 cat >"$expected" <<EOF
729 cat >`mhpath new` <<EOF
730 Date: Fri, 13 May 2011 08:21:12 -0500
731 Content-Type: multipart/alternative;
732 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
733 Content-Transfer-Encoding: 8bit
735 From: <sender@example.com>
736 To: <recipient@example.com>
737 Subject: mhfixmsg bad boundary test
739 This is a multi-part message in MIME format.
741 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
742 Content-Type: text/plain
744 The boundaries of this part don't match the header boundary.
746 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
749 cp -p `mhpath last` `mhpath new`
751 run_test
'mhfixmsg last -nofixboundary' ''
752 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
755 # check that message is not output when fed through stdin
756 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
757 check
"$expected" "$actual"
758 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
759 "$actual.err" >/dev
/null
; then
762 echo "$0: test failed, output is in $actual.err."
763 failed
=`expr ${failed:-0} + 1`
767 # check fixup of erroneous boundary in multipart (-fixboundary,
768 # enabled by default)
770 cat >"$expected" <<EOF
771 Date: Fri, 13 May 2011 08:21:12 -0500
772 Content-Type: multipart/alternative;
773 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
774 Content-Transfer-Encoding: 8bit
776 From: <sender@example.com>
777 To: <recipient@example.com>
778 Subject: mhfixmsg bad boundary test
780 This is a multi-part message in MIME format.
782 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
783 Content-Type: text/plain
785 The boundaries of this part don't match the header boundary.
787 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
790 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
791 "mhfixmsg: 17, fix multipart boundary"
792 check
"$expected" "$actual"
795 # check that text/plain part is not added to text/html in multipart/related
796 # when it shouldn't be
797 cat >`mhpath new` <<EOF
799 Date: Tue, 26 Feb 2013 18:07:20 -0600
800 Subject: multipart/related, not /alternative
801 Content-Type: multipart/related;
802 type="text/html"; boundary="----=_Part_90310_101292502.1"
804 ------=_Part_90310_101292502.1
805 Content-Type: text/html; charset="us-ascii"
806 Content-Transfer-Encoding: 7bit
809 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
810 <title>HTML Content</title>
813 This is the real content.
817 ------=_Part_90310_101292502.1
818 Content-Type: text/plain; charset="us-ascii"
819 Content-Transfer-Encoding: 7bit
821 Your email client does not support HTML messages
823 ------=_Part_90310_101292502.1--
826 cp -p `mhpath last` "$expected"
828 if [ $can_reformat_texthtml -eq 1 ]; then
829 #### lynx inserts multiple blank lines, so squeeze them.
830 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
831 check
"$expected" "$actual" 'ignore space'
837 # check handling of rfc822 message type
838 cat >"$expected" <<EOF
839 From: Test <test@example.com>
840 To: Some User <user@example.com>
841 Date: Fri, 29 Sep 2006 00:00:00
842 Message-Id: @test.nmh
843 Subject: message with message/rfc822 attachment
845 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
847 and some garbage before the attachment
849 ------- =_aaaaaaaaaa0
850 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
851 Content-Description: 1552
852 Content-Disposition: attachment; filename="1552"
854 From: Test <test@example.com>
855 To: <another_user@example.com>
856 Date: Thu, 28 Sep 2006 00:00:00
857 Message-Id: @test.nmh
858 Subject: message/rfc822 attachment
860 This is an RFC-822 message.
862 ------- =_aaaaaaaaaa0--
864 and some garbage at the end
867 cat >`mhpath new` <<EOF
868 From: Test <test@example.com>
869 To: Some User <user@example.com>
870 Date: Fri, 29 Sep 2006 00:00:00
871 Message-Id: @test.nmh
872 Subject: message with message/rfc822 attachment
874 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
876 and some garbage before the attachment
878 ------- =_aaaaaaaaaa0
879 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
880 Content-Description: 1552
881 Content-Disposition: attachment; filename="1552"
883 From: Test <test@example.com>
884 To: <another_user@example.com>
885 Date: Thu, 28 Sep 2006 00:00:00
886 Message-Id: @test.nmh
887 Subject: message/rfc822 attachment
889 This is an RFC-822 message.
891 ------- =_aaaaaaaaaa0--
893 and some garbage at the end
896 run_test
'mhfixmsg last -outfile '"$actual" ''
897 check
"$expected" "$actual"
900 # check stripping of CRs from ASCII text context
901 cat >"$expected" <<EOF
903 From: sender@example.com
904 To: recipient@example.com
905 Subject: message with CR's
906 Date: Mon, 29 Apr 2013 11:51:45 -0400
908 There are two CR-LF pairs at the end of this sentence.
912 cat >`mhpath new` <<'EOF'
914 From: sender@example.com
915 To: recipient@example.com
916 Subject: message with CR's
917 Date: Mon, 29 Apr 2013 11:51:45 -0400
919 There are two CR-LF pairs at the end of this sentence.
923 run_prog mhfixmsg last
-outfile "$actual"
924 check
"$expected" "$actual"
927 # check -replacetextplain
928 prepare_space
>"$expected" <<EOF
929 To: recipient@example.com
930 From: sender@example.com
931 Subject: mhfixmsg replacement of bad text/plain part test
933 Content-Type: multipart/alternative; boundary="----=_Part_876302"
936 Content-Type: text/plain; charset="UTF-8"
937 Content-Transfer-Encoding: 8bit
939 Yes, the text/plain part really was empty.
942 Content-Type: text/html; charset="UTF-8"
943 Content-Transfer-Encoding: 8bit
944 Content-Disposition: inline
947 <title>eticket</title>
950 Yes, the text/plain part really was empty.
954 ------=_Part_876302--
957 cat >`mhpath new` <<'EOF'
958 To: recipient@example.com
959 From: sender@example.com
960 Subject: mhfixmsg replacement of bad text/plain part test
962 Content-Type: multipart/alternative; boundary="----=_Part_876302"
965 Content-Type: text/plain; charset="iso-8859-15"
966 Content-Transfer-Encoding: 7bit
967 Content-Disposition: inline
972 Content-Type: text/html; charset="UTF-8"
973 Content-Transfer-Encoding: 8bit
974 Content-Disposition: inline
977 <title>eticket</title>
980 Yes, the text/plain part really was empty.
984 ------=_Part_876302--
987 if [ $can_reformat_texthtml -eq 1 ]; then
988 #### lynx inserts multiple blank lines, so squeeze them.
989 run_prog mhfixmsg last
-replacetextplain -outfile - | \
990 squeeze_lines
> "$actual"
991 check
"$expected" "$actual" 'ignore space'
997 # check -noreplacetextplain
998 cat >"$expected" <<EOF
999 To: recipient@example.com
1000 From: sender@example.com
1001 Subject: mhfixmsg replacement of bad text/plain part test
1003 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1006 Content-Type: text/plain; charset="iso-8859-15"
1007 Content-Transfer-Encoding: 7bit
1008 Content-Disposition: inline
1013 Content-Type: text/html; charset="UTF-8"
1014 Content-Transfer-Encoding: 8bit
1015 Content-Disposition: inline
1018 <title>eticket</title>
1021 Yes, the text/plain part really was empty.
1025 ------=_Part_876302--
1028 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1029 check
"$expected" "$actual"
1032 # check removal of extraneous trailing semicolon from header parameter list
1033 cat >"$expected" <<EOF
1034 To: recipient@example.com
1036 From: sender@example.com
1038 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1040 ------- =_aaaaaaaaaa0
1041 Content-Type: text/plain; charset="us-ascii"
1045 ------- =_aaaaaaaaaa0
1046 Content-Type: text/plain; charset="us-ascii";
1048 Content-Description: check folded headers, with and without trailing semicolon
1049 Content-Disposition: attachment;
1054 ------- =_aaaaaaaaaa0--
1057 cat >`mhpath new` <<EOF
1058 To: recipient@example.com
1060 From: sender@example.com
1062 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1064 ------- =_aaaaaaaaaa0
1065 Content-Type: text/plain; charset="us-ascii";
1069 ------- =_aaaaaaaaaa0
1070 Content-Type: text/plain; charset="us-ascii";
1072 Content-Description: check folded headers, with and without trailing semicolon
1073 Content-Disposition: attachment;
1078 ------- =_aaaaaaaaaa0--
1080 run_test
'mhfixmsg last -outfile '"$actual" ''
1081 check
"$expected" "$actual"
1085 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1088 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1089 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1090 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1092 run_test
'mhfixmsg 15' ''
1093 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1094 "${MH_TEST_DIR}/Mail/inbox/15.original"
1098 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1100 run_test
'mhfixmsg 19 -normmproc'
1101 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1102 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1106 run_test
'mhfixmsg 20 -rmmproc true'
1107 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1108 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1109 failed
=`expr ${failed:-0} + 1`
1113 # make sure there are no tmp files left over
1114 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1116 cat >"$expected" <<EOF
1119 check
"$expected" "$actual"