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
25 if grep mhfixmsg
-format-text/html
"${MH_TEST_DIR}/Mail/mhn.defaults" \
27 can_reformat_texthtml
=1
28 if grep 'mhfixmsg-format-text/html.*w3m' "${MH_TEST_DIR}/Mail/mhn.defaults" \
30 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
31 #### support testing with non-writeable $HOME, and to not leave
32 #### relics from this test if it is writeable but doesn't already
33 #### have a .w3m, and to not depend on whatever is in that if it
34 #### does already exist, overwrite $HOME if using w3m.
35 HOME
="$MHTMPDIR"; export HOME
38 echo "$0: skipping -reformat check because no text browser was found"
39 can_reformat_texthtml
=0
44 # Verified behavior consistent with compiled sendmail.
45 cat >"$expected" <<EOF
46 Usage: mhfixmsg [+folder] [msgs] [switches]
64 run_prog mhfixmsg
-help >"$actual" 2>&1
65 check
"$expected" "$actual"
69 # Verified same behavior as compiled mhfixmsg.
70 case `mhfixmsg -version` in
72 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
73 failed
=`expr ${failed:-0} + 1`;;
77 # check that non-MIME messages aren't modified
79 run_test
'mhfixmsg first -outfile '"$actual" ''
80 check
"`mhpath first`" "$actual" 'keep first'
83 # check that non-MIME messages with no bodies aren't modified
85 cat >`mhpath new` <<EOF
86 From: Test <test@example.com>
87 To: Some User <user@example.com>
88 Date: Fri, 29 Sep 2006 00:00:00
90 Subject: message with no body
93 run_test
'mhfixmsg last -outfile '"$actual" ''
94 check
"`mhpath last`" "$actual"
98 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
101 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
102 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
104 Content-Type: MULTIPART/MIXED;
105 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
106 Content-Transfer-Encoding: QUOTED-PRINTABLE
108 This message is in MIME format. The first part should be readable
110 while the remaining parts are likely unreadable without MIME-aware
113 ------=_NextPart_000_0000_00000000.00000000
114 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
115 Content-Transfer-Encoding: 8BIT
117 Some text in swedish.
119 Varf=C3=B6r inte anv=C3=A4nda...
121 ------=_NextPart_000_0000_00000000.00000000--
123 And some text after the last part.
126 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
128 run_test
'mhfixmsg last -nofixcte' ''
129 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
132 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
134 cat >"$expected" <<EOF
137 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
138 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
140 Content-Type: MULTIPART/MIXED;
141 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
142 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
143 Content-Transfer-Encoding: 8bit
145 This message is in MIME format. The first part should be readable
147 while the remaining parts are likely unreadable without MIME-aware
150 ------=_NextPart_000_0000_00000000.00000000
151 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
152 Content-Transfer-Encoding: 8BIT
154 Some text in swedish.
156 Varf=C3=B6r inte anv=C3=A4nda...
158 ------=_NextPart_000_0000_00000000.00000000--
160 And some text after the last part.
163 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
164 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
165 QUOTED-PRINTABLE with 8 bit"
166 check
"$expected" "$actual" 'keep first'
169 # check with no options: checks backup
170 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
171 folder last
>/dev
/null
172 run_test
'mhfixmsg' ''
173 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
174 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
175 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
178 # check backup with -file
179 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
180 folder last
>/dev
/null
181 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
182 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
183 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
186 # check -reformat (enabled by default): addition of text/plain part
187 # to solitary text/html part
189 prepare_space
>"$expected" <<EOF
191 From: sender@example.com
192 To: bonquiqui@example.com
194 Date: Sat, 26 Jan 2013 17:37:53 -0500
195 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
197 ------=_nmh-multipart
198 Content-Type: text/plain; charset="Windows-1252"
199 Content-Transfer-Encoding: 8bit
201 Need to go! Need ... to ... go!
203 ------=_nmh-multipart
204 Content-Type: text/html; charset="Windows-1252"
205 Content-Transfer-Encoding: 8bit
209 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
210 <meta name="Generator" content="Microsoft Exchange Server">
211 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
215 <div>Need to go! Need ... to ... go!</div>
219 ------=_nmh-multipart--
222 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
224 From: sender@example.com
225 To: bonquiqui@example.com
227 Date: Sat, 26 Jan 2013 17:37:53 -0500
228 Content-Type: text/html; charset="Windows-1252"
229 Content-Transfer-Encoding: quoted-printable
233 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
235 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
236 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
237 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
241 <div>Need to go! Need ... to ... go!</div>
246 if [ $can_reformat_texthtml -eq 1 ]; then
247 printf '%s\n' "mhfixmsg: 12, insert text/plain part
248 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
251 #### lynx inserts multiple blank lines, so squeeze them.
252 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
253 squeeze_lines
>"$actual"
254 check
"$expected" "$actual" 'ignore space'
255 check
"$expected.err" "$actual.err"
261 # check implicit -file with absolute pathname
262 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
265 # check handling of boundary string that appears in message body
267 prepare_space
>"$expected" <<EOF
269 From: sender@example.com
270 To: bonquiqui@example.com
272 Date: Sat, 26 Jan 2013 17:37:53 -0500
273 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
275 ------=_nmh-multipart-3
276 Content-Type: text/plain; charset="Windows-1252"
277 Content-Transfer-Encoding: 8bit
279 ------=_nmh-multipart
280 ------=_nmh-multipart-1
281 ------=_nmh-multipart-2
283 ------=_nmh-multipart-3
284 Content-Type: text/html; charset="Windows-1252"
285 Content-Transfer-Encoding: 8bit
289 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
290 <meta name="Generator" content="Microsoft Exchange Server">
291 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
294 ------=_nmh-multipart<br>
295 ------=_nmh-multipart-1<br>
296 ------=_nmh-multipart-2<br>
300 ------=_nmh-multipart-3--
303 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
305 From: sender@example.com
306 To: bonquiqui@example.com
308 Date: Sat, 26 Jan 2013 17:37:53 -0500
309 Content-Type: text/html; charset="Windows-1252"
310 Content-Transfer-Encoding: quoted-printable
314 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
316 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
317 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
318 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
321 ------=3D_nmh-multipart<br>
322 ------=3D_nmh-multipart-1<br>
323 ------=3D_nmh-multipart-2<br>
328 if [ $can_reformat_texthtml -eq 1 ]; then
329 printf '%s\n' "mhfixmsg: 12, insert text/plain part
330 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
333 #### lynx inserts multiple blank lines, so squeeze them.
334 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
335 squeeze_lines
>"$actual"
336 check
"$expected" "$actual" 'ignore space'
337 check
"$expected.err" "$actual.err"
344 prepare_space
>"$expected" <<EOF
346 From: sender@example.com
347 To: bonquiqui@example.com
349 Date: Sat, 26 Jan 2013 17:37:53 -0500
350 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
352 ------=_nmh-multipart
353 Content-Type: text/plain; charset="Windows-1252"
354 Content-Transfer-Encoding: 8bit
356 Need to go! Need ... to ... go!
358 ------=_nmh-multipart
359 Content-Type: text/html; charset="Windows-1252"
360 Content-Transfer-Encoding: quoted-printable
364 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
366 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
367 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
368 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
372 <div>Need to go! Need ... to ... go!</div>
376 ------=_nmh-multipart--
379 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
381 From: sender@example.com
382 To: bonquiqui@example.com
384 Date: Sat, 26 Jan 2013 17:37:53 -0500
385 Content-Type: text/html; charset="Windows-1252"
386 Content-Transfer-Encoding: quoted-printable
390 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
392 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
393 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
394 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
398 <div>Need to go! Need ... to ... go!</div>
403 if [ $can_reformat_texthtml -eq 1 ]; then
404 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
406 #### lynx inserts multiple blank lines, so squeeze them.
407 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
408 squeeze_lines
>"$actual"
409 check
"$expected" "$actual" 'ignore space'
410 check
"$expected.err" "$actual.err"
416 # check -decode (enabled by default)
417 cat >"$expected" <<EOF
418 To: recipient@example.com
419 From: sender@example.com
420 Subject: mhfixmsg decode test
422 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
424 ------- =_aaaaaaaaaa0
425 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
426 Content-Disposition: attachment; filename="test4.txt"
427 Content-Transfer-Encoding: 8bit
429 This is a text/plain part.
431 ------- =_aaaaaaaaaa0--
434 cat >`mhpath new` <<EOF
435 To: recipient@example.com
436 From: sender@example.com
437 Subject: mhfixmsg decode test
439 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
441 ------- =_aaaaaaaaaa0
442 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
443 Content-Disposition: attachment; filename="test4.txt"
444 Content-Transfer-Encoding: base64
446 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
448 ------- =_aaaaaaaaaa0--
451 run_prog mhfixmsg last
-outfile "$actual"
452 check
"$expected" "$actual"
455 # check -decode with more complicated content structure
457 To: recipient@example.com
458 From: sender@example.com
459 Subject: mhfixmsg decode test 2
461 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
463 This is additional content before the first subpart of the multipart.
465 ------- =_aaaaaaaaaa0
466 Content-Type: multipart/related;
467 type="multipart/alternative";
468 boundary="subpart__1.1"
471 Content-Type: text/plain; charset="iso-8859-1"
472 Content-Disposition: attachment; filename="test1.txt"
474 This is the first text/plain part, in a subpart.
478 This is additional content after the last subpart of the multipart.
480 ------- =_aaaaaaaaaa0
481 Content-Type: text/plain; charset="iso-8859-1"
482 Content-Disposition: attachment; filename="test2.txt"
483 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
484 Content-Transfer-Encoding: 8bit
486 This is the second text/plain part.
488 ------- =_aaaaaaaaaa0
489 Content-Type: text/plain; charset="iso-8859-1"
490 Content-Disposition: attachment; filename="test3.txt"
492 This is the third text/plain part.
494 ------- =_aaaaaaaaaa0
495 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
496 Content-Disposition: attachment; filename="test4.txt"
497 Content-Transfer-Encoding: 8bit
499 This is the fourth text/plain part.
501 ------- =_aaaaaaaaaa0--
503 This is additional content after the last subpart of the multipart.
506 cat >`mhpath new` <<EOF
507 To: recipient@example.com
508 From: sender@example.com
509 Subject: mhfixmsg decode test 2
511 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
513 This is additional content before the first subpart of the multipart.
515 ------- =_aaaaaaaaaa0
516 Content-Type: multipart/related;
517 type="multipart/alternative";
518 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="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=\"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 textcodeset test
685 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
687 ------- =_aaaaaaaaaa0
688 Content-Type: text/plain; charset="utf-8"; name="square.txt"
689 Content-Disposition: attachment; filename="square.txt"
690 Content-Transfer-Encoding: 8bit
694 ------- =_aaaaaaaaaa0--
697 #### Generated the encoded text below with:
698 #### $ printf '\xbd\xb2=\xbc\n' | base64
699 cat >`mhpath new` <<EOF
700 To: recipient@example.com
701 From: sender@example.com
702 Subject: mhfixmsg textcodeset test
704 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
706 ------- =_aaaaaaaaaa0
707 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
708 Content-Disposition: attachment; filename="square.txt"
709 Content-Transfer-Encoding: base64
713 ------- =_aaaaaaaaaa0--
717 run_prog mhfixmsg last
-textcodeset utf
-8 -outfile "$actual" 2>"$actual.err"
718 if grep "mhfixmsg: Can't convert .* to .* without iconv" "$actual.err" \
720 echo "$0: skipping -textcodeset check because nmh was built without iconv"
721 rm -f "$expected" "$actual" "$actual.err"
723 check
"$expected" "$actual"
729 # check -nofixboundary
730 cat >"$expected" <<EOF
733 cat >`mhpath new` <<EOF
734 Date: Fri, 13 May 2011 08:21:12 -0500
735 Content-Type: multipart/alternative;
736 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
737 Content-Transfer-Encoding: 8bit
739 From: <sender@example.com>
740 To: <recipient@example.com>
741 Subject: mhfixmsg bad boundary test
743 This is a multi-part message in MIME format.
745 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
746 Content-Type: text/plain
748 The boundaries of this part don't match the header boundary.
750 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
753 cp -p `mhpath last` `mhpath new`
755 run_test
'mhfixmsg last -nofixboundary' ''
756 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
759 # check that message is not output when fed through stdin
760 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
761 check
"$expected" "$actual"
762 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
763 "$actual.err" >/dev
/null
; then
766 echo "$0: test failed, output is in $actual.err."
767 failed
=`expr ${failed:-0} + 1`
771 # check fixup of erroneous boundary in multipart (-fixboundary,
772 # enabled by default)
774 cat >"$expected" <<EOF
775 Date: Fri, 13 May 2011 08:21:12 -0500
776 Content-Type: multipart/alternative;
777 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
778 Content-Transfer-Encoding: 8bit
780 From: <sender@example.com>
781 To: <recipient@example.com>
782 Subject: mhfixmsg bad boundary test
784 This is a multi-part message in MIME format.
786 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
787 Content-Type: text/plain
789 The boundaries of this part don't match the header boundary.
791 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
794 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
795 "mhfixmsg: 17, fix multipart boundary"
796 check
"$expected" "$actual"
799 # check that text/plain part is added to lone text/html in multipart/related
800 prepare_space
>"$expected" <<EOF
802 Date: Tue, 26 Feb 2013 18:07:20 -0600
803 Subject: multipart/related, not /alternative
804 Content-Type: multipart/related;
805 boundary="----=_Part_90310_101292502.1"
807 ------=_Part_90310_101292502.1
808 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
810 ------=_nmh-multipart1
811 Content-Type: text/plain; charset="us-ascii"
812 Content-Transfer-Encoding: 7bit
814 This is the real content.
816 ------=_nmh-multipart1
817 Content-Type: text/html; charset="us-ascii"
818 Content-Transfer-Encoding: 7bit
821 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
822 <title>HTML Content</title>
825 This is the real content.
829 ------=_nmh-multipart1--
831 ------=_Part_90310_101292502.1
832 Content-Type: text/plain; charset="us-ascii"
833 Content-Transfer-Encoding: 7bit
835 Your email client does not support HTML messages
837 ------=_Part_90310_101292502.1--
840 cat >`mhpath new` <<EOF
842 Date: Tue, 26 Feb 2013 18:07:20 -0600
843 Subject: multipart/related, not /alternative
844 Content-Type: multipart/related;
845 boundary="----=_Part_90310_101292502.1"
847 ------=_Part_90310_101292502.1
848 Content-Type: text/html; charset="us-ascii"
849 Content-Transfer-Encoding: 7bit
852 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
853 <title>HTML Content</title>
856 This is the real content.
859 ------=_Part_90310_101292502.1
860 Content-Type: text/plain; charset="us-ascii"
861 Content-Transfer-Encoding: 7bit
863 Your email client does not support HTML messages
864 ------=_Part_90310_101292502.1--
867 if [ $can_reformat_texthtml -eq 1 ]; then
868 #### lynx inserts multiple blank lines, so squeeze them.
869 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
870 check
"$expected" "$actual" 'ignore space'
876 # check handling of rfc822 message type
877 cat >"$expected" <<EOF
878 From: Test <test@example.com>
879 To: Some User <user@example.com>
880 Date: Fri, 29 Sep 2006 00:00:00
881 Message-Id: @test.nmh
882 Subject: message with message/rfc822 attachment
884 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
886 and some garbage before the attachment
888 ------- =_aaaaaaaaaa0
889 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
890 Content-Description: 1552
891 Content-Disposition: attachment; filename="1552"
893 From: Test <test@example.com>
894 To: <another_user@example.com>
895 Date: Thu, 28 Sep 2006 00:00:00
896 Message-Id: @test.nmh
897 Subject: message/rfc822 attachment
899 This is an RFC-822 message.
901 ------- =_aaaaaaaaaa0--
903 and some garbage at the end
906 cat >`mhpath new` <<EOF
907 From: Test <test@example.com>
908 To: Some User <user@example.com>
909 Date: Fri, 29 Sep 2006 00:00:00
910 Message-Id: @test.nmh
911 Subject: message with message/rfc822 attachment
913 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
915 and some garbage before the attachment
917 ------- =_aaaaaaaaaa0
918 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
919 Content-Description: 1552
920 Content-Disposition: attachment; filename="1552"
922 From: Test <test@example.com>
923 To: <another_user@example.com>
924 Date: Thu, 28 Sep 2006 00:00:00
925 Message-Id: @test.nmh
926 Subject: message/rfc822 attachment
928 This is an RFC-822 message.
930 ------- =_aaaaaaaaaa0--
932 and some garbage at the end
935 run_test
'mhfixmsg last -outfile '"$actual" ''
936 check
"$expected" "$actual"
939 # check stripping of CRs from ASCII text context
940 cat >"$expected" <<EOF
942 From: sender@example.com
943 To: recipient@example.com
944 Subject: message with CR's
945 Date: Mon, 29 Apr 2013 11:51:45 -0400
947 There are two CR-LF pairs at the end of this sentence.
951 cat >`mhpath new` <<'EOF'
953 From: sender@example.com
954 To: recipient@example.com
955 Subject: message with CR's
956 Date: Mon, 29 Apr 2013 11:51:45 -0400
958 There are two CR-LF pairs at the end of this sentence.
962 run_prog mhfixmsg last
-outfile "$actual"
963 check
"$expected" "$actual"
966 # check -replacetextplain
967 prepare_space
>"$expected" <<EOF
968 To: recipient@example.com
969 From: sender@example.com
970 Subject: mhfixmsg replacement of bad text/plain part test
972 Content-Type: multipart/alternative; boundary="----=_Part_876302"
975 Content-Type: text/plain; charset="UTF-8"
976 Content-Transfer-Encoding: 8bit
978 Yes, the text/plain part really was empty.
981 Content-Type: text/html; charset="UTF-8"
982 Content-Transfer-Encoding: 8bit
983 Content-Disposition: inline
986 <title>eticket</title>
989 Yes, the text/plain part really was empty.
993 ------=_Part_876302--
996 cat >`mhpath new` <<'EOF'
997 To: recipient@example.com
998 From: sender@example.com
999 Subject: mhfixmsg replacement of bad text/plain part test
1001 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1004 Content-Type: text/plain; charset="iso-8859-15"
1005 Content-Transfer-Encoding: 7bit
1006 Content-Disposition: inline
1011 Content-Type: text/html; charset="UTF-8"
1012 Content-Transfer-Encoding: 8bit
1013 Content-Disposition: inline
1016 <title>eticket</title>
1019 Yes, the text/plain part really was empty.
1023 ------=_Part_876302--
1026 if [ $can_reformat_texthtml -eq 1 ]; then
1027 #### lynx inserts multiple blank lines, so squeeze them.
1028 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1029 squeeze_lines
> "$actual"
1030 check
"$expected" "$actual" 'ignore space'
1036 # check -noreplacetextplain
1037 cat >"$expected" <<EOF
1038 To: recipient@example.com
1039 From: sender@example.com
1040 Subject: mhfixmsg replacement of bad text/plain part test
1042 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1045 Content-Type: text/plain; charset="iso-8859-15"
1046 Content-Transfer-Encoding: 7bit
1047 Content-Disposition: inline
1052 Content-Type: text/html; charset="UTF-8"
1053 Content-Transfer-Encoding: 8bit
1054 Content-Disposition: inline
1057 <title>eticket</title>
1060 Yes, the text/plain part really was empty.
1064 ------=_Part_876302--
1067 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1068 check
"$expected" "$actual"
1072 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1075 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1076 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1077 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1079 run_test
'mhfixmsg 15' ''
1080 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1081 "${MH_TEST_DIR}/Mail/inbox/15.original"
1085 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1087 run_test
'mhfixmsg 19 -normmproc'
1088 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1089 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1093 run_test
'mhfixmsg 20 -rmmproc true'
1094 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1095 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1096 failed
=`expr ${failed:-0} + 1`
1100 # make sure there are no tmp files left over
1101 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1103 cat >"$expected" <<EOF
1106 check
"$expected" "$actual"