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="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 added to lone text/html in multipart/related
796 prepare_space
>"$expected" <<EOF
798 Date: Tue, 26 Feb 2013 18:07:20 -0600
799 Subject: multipart/related, not /alternative
800 Content-Type: multipart/related;
801 boundary="----=_Part_90310_101292502.1"
803 ------=_Part_90310_101292502.1
804 Content-Type: multipart/alternative; boundary="----=_nmh-multipart1"
806 ------=_nmh-multipart1
807 Content-Type: text/plain; charset="us-ascii"
808 Content-Transfer-Encoding: 7bit
810 This is the real content.
812 ------=_nmh-multipart1
813 Content-Type: text/html; charset="us-ascii"
814 Content-Transfer-Encoding: 7bit
817 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
818 <title>HTML Content</title>
821 This is the real content.
825 ------=_nmh-multipart1--
827 ------=_Part_90310_101292502.1
828 Content-Type: text/plain; charset="us-ascii"
829 Content-Transfer-Encoding: 7bit
831 Your email client does not support HTML messages
833 ------=_Part_90310_101292502.1--
836 cat >`mhpath new` <<EOF
838 Date: Tue, 26 Feb 2013 18:07:20 -0600
839 Subject: multipart/related, not /alternative
840 Content-Type: multipart/related;
841 boundary="----=_Part_90310_101292502.1"
843 ------=_Part_90310_101292502.1
844 Content-Type: text/html; charset="us-ascii"
845 Content-Transfer-Encoding: 7bit
848 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
849 <title>HTML Content</title>
852 This is the real content.
855 ------=_Part_90310_101292502.1
856 Content-Type: text/plain; charset="us-ascii"
857 Content-Transfer-Encoding: 7bit
859 Your email client does not support HTML messages
860 ------=_Part_90310_101292502.1--
863 if [ $can_reformat_texthtml -eq 1 ]; then
864 #### lynx inserts multiple blank lines, so squeeze them.
865 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
866 check
"$expected" "$actual" 'ignore space'
872 # check handling of rfc822 message type
873 cat >"$expected" <<EOF
874 From: Test <test@example.com>
875 To: Some User <user@example.com>
876 Date: Fri, 29 Sep 2006 00:00:00
877 Message-Id: @test.nmh
878 Subject: message with message/rfc822 attachment
880 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
882 and some garbage before the attachment
884 ------- =_aaaaaaaaaa0
885 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
886 Content-Description: 1552
887 Content-Disposition: attachment; filename="1552"
889 From: Test <test@example.com>
890 To: <another_user@example.com>
891 Date: Thu, 28 Sep 2006 00:00:00
892 Message-Id: @test.nmh
893 Subject: message/rfc822 attachment
895 This is an RFC-822 message.
897 ------- =_aaaaaaaaaa0--
899 and some garbage at the end
902 cat >`mhpath new` <<EOF
903 From: Test <test@example.com>
904 To: Some User <user@example.com>
905 Date: Fri, 29 Sep 2006 00:00:00
906 Message-Id: @test.nmh
907 Subject: message with message/rfc822 attachment
909 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
911 and some garbage before the attachment
913 ------- =_aaaaaaaaaa0
914 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
915 Content-Description: 1552
916 Content-Disposition: attachment; filename="1552"
918 From: Test <test@example.com>
919 To: <another_user@example.com>
920 Date: Thu, 28 Sep 2006 00:00:00
921 Message-Id: @test.nmh
922 Subject: message/rfc822 attachment
924 This is an RFC-822 message.
926 ------- =_aaaaaaaaaa0--
928 and some garbage at the end
931 run_test
'mhfixmsg last -outfile '"$actual" ''
932 check
"$expected" "$actual"
935 # check stripping of CRs from ASCII text context
936 cat >"$expected" <<EOF
938 From: sender@example.com
939 To: recipient@example.com
940 Subject: message with CR's
941 Date: Mon, 29 Apr 2013 11:51:45 -0400
943 There are two CR-LF pairs at the end of this sentence.
947 cat >`mhpath new` <<'EOF'
949 From: sender@example.com
950 To: recipient@example.com
951 Subject: message with CR's
952 Date: Mon, 29 Apr 2013 11:51:45 -0400
954 There are two CR-LF pairs at the end of this sentence.
958 run_prog mhfixmsg last
-outfile "$actual"
959 check
"$expected" "$actual"
962 # check -replacetextplain
963 prepare_space
>"$expected" <<EOF
964 To: recipient@example.com
965 From: sender@example.com
966 Subject: mhfixmsg replacement of bad text/plain part test
968 Content-Type: multipart/alternative; boundary="----=_Part_876302"
971 Content-Type: text/plain; charset="UTF-8"
972 Content-Transfer-Encoding: 8bit
974 Yes, the text/plain part really was empty.
977 Content-Type: text/html; charset="UTF-8"
978 Content-Transfer-Encoding: 8bit
979 Content-Disposition: inline
982 <title>eticket</title>
985 Yes, the text/plain part really was empty.
989 ------=_Part_876302--
992 cat >`mhpath new` <<'EOF'
993 To: recipient@example.com
994 From: sender@example.com
995 Subject: mhfixmsg replacement of bad text/plain part test
997 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1000 Content-Type: text/plain; charset="iso-8859-15"
1001 Content-Transfer-Encoding: 7bit
1002 Content-Disposition: inline
1007 Content-Type: text/html; charset="UTF-8"
1008 Content-Transfer-Encoding: 8bit
1009 Content-Disposition: inline
1012 <title>eticket</title>
1015 Yes, the text/plain part really was empty.
1019 ------=_Part_876302--
1022 if [ $can_reformat_texthtml -eq 1 ]; then
1023 #### lynx inserts multiple blank lines, so squeeze them.
1024 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1025 squeeze_lines
> "$actual"
1026 check
"$expected" "$actual" 'ignore space'
1032 # check -noreplacetextplain
1033 cat >"$expected" <<EOF
1034 To: recipient@example.com
1035 From: sender@example.com
1036 Subject: mhfixmsg replacement of bad text/plain part test
1038 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1041 Content-Type: text/plain; charset="iso-8859-15"
1042 Content-Transfer-Encoding: 7bit
1043 Content-Disposition: inline
1048 Content-Type: text/html; charset="UTF-8"
1049 Content-Transfer-Encoding: 8bit
1050 Content-Disposition: inline
1053 <title>eticket</title>
1056 Yes, the text/plain part really was empty.
1060 ------=_Part_876302--
1063 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1064 check
"$expected" "$actual"
1068 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1071 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1072 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1073 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1075 run_test
'mhfixmsg 15' ''
1076 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1077 "${MH_TEST_DIR}/Mail/inbox/15.original"
1081 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1083 run_test
'mhfixmsg 19 -normmproc'
1084 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1085 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1089 run_test
'mhfixmsg 20 -rmmproc true'
1090 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1091 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1092 failed
=`expr ${failed:-0} + 1`
1096 # make sure there are no tmp files left over
1097 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1099 cat >"$expected" <<EOF
1102 check
"$expected" "$actual"