2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"${MH_OBJ_DIR}/test/common.sh"
19 #### Make sure that html-to-text conversion is what we expect.
20 require_locale en_US.utf
-8 en_US.utf8
21 LC_ALL
=en_US.UTF
-8; export LC_ALL
23 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
24 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
25 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
26 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
28 mhn_defaults
="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
30 if grep mhfixmsg
-format-text/html
"${mhn_defaults}" \
32 can_reformat_texthtml
=1
33 if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
35 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
36 #### support testing with non-writeable $HOME, and to not leave
37 #### relics from this test if it is writeable but doesn't already
38 #### have a .w3m, and to not depend on whatever is in that if it
39 #### does already exist, overwrite $HOME if using w3m.
40 HOME
="$MHTMPDIR"; export HOME
43 echo "$0: skipping -reformat check because no text browser was found"
44 can_reformat_texthtml
=0
49 cat >"$expected" <<EOF
50 Usage: mhfixmsg [+folder] [msgs] [switches]
70 run_prog mhfixmsg
-help >"$actual" 2>&1
71 check
"$expected" "$actual"
75 case `mhfixmsg -version` in
77 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
78 failed
=`expr ${failed:-0} + 1`;;
82 # check that non-MIME messages aren't modified
84 run_test
'mhfixmsg first -outfile '"$actual" ''
85 check
"`mhpath first`" "$actual" 'keep first'
88 # check that non-MIME messages with no bodies aren't modified
90 cat >`mhpath new` <<EOF
91 From: Test <test@example.com>
92 To: Some User <user@example.com>
93 Date: Fri, 29 Sep 2006 00:00:00
95 Subject: message with no body
98 run_test
'mhfixmsg last -outfile '"$actual" ''
99 check
"`mhpath last`" "$actual"
103 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
106 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
107 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
109 Content-Type: MULTIPART/MIXED;
110 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
111 Content-Transfer-Encoding: QUOTED-PRINTABLE
113 This message is in MIME format. The first part should be readable
115 while the remaining parts are likely unreadable without MIME-aware
118 ------=_NextPart_000_0000_00000000.00000000
119 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
120 Content-Transfer-Encoding: 8BIT
122 Some text in swedish.
124 Varf=C3=B6r inte anv=C3=A4nda...
126 ------=_NextPart_000_0000_00000000.00000000--
128 And some text after the last part.
131 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
133 run_test
'mhfixmsg last -nofixcte' ''
134 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
137 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
139 cat >"$expected" <<EOF
142 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
143 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
145 Content-Type: MULTIPART/MIXED;
146 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
147 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
148 Content-Transfer-Encoding: 8bit
150 This message is in MIME format. The first part should be readable
152 while the remaining parts are likely unreadable without MIME-aware
155 ------=_NextPart_000_0000_00000000.00000000
156 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
157 Content-Transfer-Encoding: 8BIT
159 Some text in swedish.
161 Varf=C3=B6r inte anv=C3=A4nda...
163 ------=_NextPart_000_0000_00000000.00000000--
165 And some text after the last part.
168 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
169 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
170 QUOTED-PRINTABLE with 8 bit"
171 check
"$expected" "$actual" 'keep first'
174 # check with no options: checks backup
175 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
176 folder last
>/dev
/null
177 run_test
'mhfixmsg' ''
178 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
179 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
180 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
183 # check backup with -file
184 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
185 folder last
>/dev
/null
186 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
187 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
188 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
191 # check -reformat (enabled by default): addition of text/plain part
192 # to solitary text/html part
194 prepare_space
>"$expected" <<EOF
196 From: sender@example.com
197 To: bonquiqui@example.com
199 Date: Sat, 26 Jan 2013 17:37:53 -0500
200 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
202 ------=_nmh-multipart
203 Content-Type: text/plain; charset="Windows-1252"
204 Content-Transfer-Encoding: 8bit
206 Need to go! Need ... to ... go!
208 ------=_nmh-multipart
209 Content-Type: text/html; charset="Windows-1252"
210 Content-Transfer-Encoding: 8bit
214 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
215 <meta name="Generator" content="Microsoft Exchange Server">
216 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
220 <div>Need to go! Need ... to ... go!</div>
224 ------=_nmh-multipart--
227 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
229 From: sender@example.com
230 To: bonquiqui@example.com
232 Date: Sat, 26 Jan 2013 17:37:53 -0500
233 Content-Type: text/html; charset="Windows-1252"
234 Content-Transfer-Encoding: quoted-printable
238 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
240 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
241 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
242 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
246 <div>Need to go! Need ... to ... go!</div>
251 if [ $can_reformat_texthtml -eq 1 ]; then
252 printf '%s\n' "mhfixmsg: 12, insert text/plain part
253 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
256 #### lynx inserts multiple blank lines, so squeeze them.
257 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
258 squeeze_lines
>"$actual"
259 check
"$expected" "$actual" 'ignore space'
260 check
"$expected.err" "$actual.err"
266 # check implicit -file with absolute pathname
267 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
270 # check handling of boundary string that appears in message body
272 prepare_space
>"$expected" <<EOF
274 From: sender@example.com
275 To: bonquiqui@example.com
277 Date: Sat, 26 Jan 2013 17:37:53 -0500
278 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
280 ------=_nmh-multipart-3
281 Content-Type: text/plain; charset="Windows-1252"
282 Content-Transfer-Encoding: 8bit
284 ------=_nmh-multipart
285 ------=_nmh-multipart-1
286 ------=_nmh-multipart-2
288 ------=_nmh-multipart-3
289 Content-Type: text/html; charset="Windows-1252"
290 Content-Transfer-Encoding: 8bit
294 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
295 <meta name="Generator" content="Microsoft Exchange Server">
296 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
299 ------=_nmh-multipart<br>
300 ------=_nmh-multipart-1<br>
301 ------=_nmh-multipart-2<br>
305 ------=_nmh-multipart-3--
308 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
310 From: sender@example.com
311 To: bonquiqui@example.com
313 Date: Sat, 26 Jan 2013 17:37:53 -0500
314 Content-Type: text/html; charset="Windows-1252"
315 Content-Transfer-Encoding: quoted-printable
319 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
321 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
322 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
323 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
326 ------=3D_nmh-multipart<br>
327 ------=3D_nmh-multipart-1<br>
328 ------=3D_nmh-multipart-2<br>
333 if [ $can_reformat_texthtml -eq 1 ]; then
334 printf '%s\n' "mhfixmsg: 12, insert text/plain part
335 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
338 #### lynx inserts multiple blank lines, so squeeze them.
339 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
340 squeeze_lines
>"$actual"
341 check
"$expected" "$actual" 'ignore space'
342 check
"$expected.err" "$actual.err"
349 prepare_space
>"$expected" <<EOF
351 From: sender@example.com
352 To: bonquiqui@example.com
354 Date: Sat, 26 Jan 2013 17:37:53 -0500
355 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
357 ------=_nmh-multipart
358 Content-Type: text/plain; charset="Windows-1252"
359 Content-Transfer-Encoding: 8bit
361 Need to go! Need ... to ... go!
363 ------=_nmh-multipart
364 Content-Type: text/html; charset="Windows-1252"
365 Content-Transfer-Encoding: quoted-printable
369 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
371 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
372 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
373 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
377 <div>Need to go! Need ... to ... go!</div>
381 ------=_nmh-multipart--
384 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
386 From: sender@example.com
387 To: bonquiqui@example.com
389 Date: Sat, 26 Jan 2013 17:37:53 -0500
390 Content-Type: text/html; charset="Windows-1252"
391 Content-Transfer-Encoding: quoted-printable
395 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
397 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
398 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
399 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
403 <div>Need to go! Need ... to ... go!</div>
408 if [ $can_reformat_texthtml -eq 1 ]; then
409 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
411 #### lynx inserts multiple blank lines, so squeeze them.
412 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
413 squeeze_lines
>"$actual"
414 check
"$expected" "$actual" 'ignore space'
415 check
"$expected.err" "$actual.err"
421 # check -decode (enabled by default)
422 cat >"$expected" <<EOF
423 To: recipient@example.com
424 From: sender@example.com
425 Subject: mhfixmsg decode test
427 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
429 ------- =_aaaaaaaaaa0
430 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
431 Content-Disposition: attachment; filename="test4.txt"
432 Content-Transfer-Encoding: 8bit
434 This is a text/plain part.
436 ------- =_aaaaaaaaaa0--
439 cat >`mhpath new` <<EOF
440 To: recipient@example.com
441 From: sender@example.com
442 Subject: mhfixmsg decode test
444 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
446 ------- =_aaaaaaaaaa0
447 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
448 Content-Disposition: attachment; filename="test4.txt"
449 Content-Transfer-Encoding: base64
451 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
453 ------- =_aaaaaaaaaa0--
456 run_prog mhfixmsg last
-outfile "$actual"
457 check
"$expected" "$actual"
460 # check -decode with more complicated content structure
462 To: recipient@example.com
463 From: sender@example.com
464 Subject: mhfixmsg decode test 2
466 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
468 This is additional content before the first subpart of the multipart.
470 ------- =_aaaaaaaaaa0
471 Content-Type: multipart/related;
472 type="text/plain"; boundary="subpart__1.1"
475 Content-Type: text/plain; charset="iso-8859-1"
476 Content-Disposition: attachment; filename="test1.txt"
478 This is the first text/plain part, in a subpart.
482 This is additional content after the last subpart of the multipart.
484 ------- =_aaaaaaaaaa0
485 Content-Type: text/plain; charset="iso-8859-1"
486 Content-Disposition: attachment; filename="test2.txt"
487 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
488 Content-Transfer-Encoding: 8bit
490 This is the second text/plain part.
492 ------- =_aaaaaaaaaa0
493 Content-Type: text/plain; charset="iso-8859-1"
494 Content-Disposition: attachment; filename="test3.txt"
496 This is the third text/plain part.
498 ------- =_aaaaaaaaaa0
499 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
500 Content-Disposition: attachment; filename="test4.txt"
501 Content-Transfer-Encoding: 8bit
503 This is the fourth text/plain part.
505 ------- =_aaaaaaaaaa0--
507 This is additional content after the last subpart of the multipart.
510 cat >`mhpath new` <<EOF
511 To: recipient@example.com
512 From: sender@example.com
513 Subject: mhfixmsg decode test 2
515 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
517 This is additional content before the first subpart of the multipart.
519 ------- =_aaaaaaaaaa0
520 Content-Type: multipart/related;
521 type="text/plain"; boundary="subpart__1.1"
524 Content-Type: text/plain; charset="iso-8859-1"
525 Content-Disposition: attachment; filename="test1.txt"
527 This is the first text/plain part, in a subpart.
531 This is additional content after the last subpart of the multipart.
533 ------- =_aaaaaaaaaa0
534 Content-Type: text/plain; charset="iso-8859-1"
535 Content-Disposition: attachment; filename="test2.txt"
536 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
537 Content-Transfer-Encoding: quoted-printable
539 This is the second text/plain part.
541 ------- =_aaaaaaaaaa0
542 Content-Type: text/plain; charset="iso-8859-1"
543 Content-Disposition: attachment; filename="test3.txt"
545 This is the third text/plain part.
547 ------- =_aaaaaaaaaa0
548 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
549 Content-Disposition: attachment; filename="test4.txt"
550 Content-Transfer-Encoding: base64
552 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
554 ------- =_aaaaaaaaaa0--
556 This is additional content after the last subpart of the multipart.
558 run_prog mhfixmsg last
-outfile "$actual"
559 check
"$expected" "$actual"
562 # check attempted -decode of binary text
563 #### Generated the encoded text below with:
564 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
565 cat >`mhpath new` <<EOF
566 To: recipient@example.com
567 From: sender@example.com
568 Subject: mhfixmsg attempted binary decode test
570 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
572 ------- =_aaaaaaaaaa0
573 Content-Type: text/plain; charset="iso-8859-1"; name="nul+square.txt"
574 Content-Transfer-Encoding: base64
578 ------- =_aaaaaaaaaa0--
581 cp -p `mhpath last` "$expected"
582 run_prog mhfixmsg last
583 check
`mhpath last` "$expected" 'keep first'
586 # check -decode of binary text
587 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
588 From: sender@example.com
589 Subject: mhfixmsg binary decode test
591 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
593 ------- =_aaaaaaaaaa0
594 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"nul+square.txt\"
595 Content-Transfer-Encoding: binary
599 ------- =_aaaaaaaaaa0--
601 ## output_content() in mhoutsbr.c can't handle binary content.
602 ## mhfixmsg last -decodetext binary -outfile "$actual"
603 ## check "$expected" "$actual"
608 # check that -reformat succeeds when decode of binary text fails
609 prepare_space
>"$expected" <<'EOF'
611 Date: Thu, 11 Apr 2013 02:47:08 -0700
613 From: <sender@example.com>
614 Subject: body requires binary encoding
615 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
617 ------=_nmh-multipart
618 Content-Type: text/plain; charset="ISO-8859-1"
619 Content-Transfer-Encoding: 8bit
624 Vehicle License Fee $1.84
627 ------=_nmh-multipart
628 Content-Type: text/html; charset="ISO-8859-1"
629 Content-Transfer-Encoding: quoted-printable
634 cat >`mhpath new` <<'EOF'
636 Content-Type: text/html; charset="ISO-8859-1"
637 Content-Transfer-Encoding: quoted-printable
638 Date: Thu, 11 Apr 2013 02:47:08 -0700
640 From: <sender@example.com>
641 Subject: body requires binary encoding
644 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
645 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
646 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
647 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
648 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
649 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
650 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
651 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
652 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
653 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
654 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
655 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
656 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
657 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
658 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
659 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
660 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
661 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
662 #333333" size=3D"2">$6.00</font></td></tr>
668 if [ $can_reformat_texthtml -eq 1 ]; then
669 #### lynx inserts multiple blank lines, so squeeze them.
670 #### Truncate to avoid comparing the html portion because it can
671 #### get reformatted.
672 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
673 check
"$expected" "$actual" 'ignore space'
675 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
681 # Also checks preservation of attributes after one (charset) that is
683 cat >"$expected" <<EOF
684 To: recipient@example.com
685 From: sender@example.com
686 Subject: mhfixmsg textcharset test
688 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
690 ------- =_aaaaaaaaaa0
691 Content-Type: text/plain; charset="utf-8"; name="square.txt"
692 Content-Disposition: attachment; filename="square.txt"
693 Content-Transfer-Encoding: 8bit
697 ------- =_aaaaaaaaaa0--
700 #### Generated the encoded text below with:
701 #### $ printf '\xbd\xb2=\xbc\n' | base64
702 cat >`mhpath new` <<EOF
703 To: recipient@example.com
704 From: sender@example.com
705 Subject: mhfixmsg textcharset test
707 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
709 ------- =_aaaaaaaaaa0
710 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
711 Content-Disposition: attachment; filename="square.txt"
712 Content-Transfer-Encoding: base64
716 ------- =_aaaaaaaaaa0--
719 if test "$ICONV_ENABLED" -eq 1; then
720 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
721 check
"$expected" "$actual"
723 echo "$0: skipping -textcharset check because nmh was built without iconv"
728 # check -nofixboundary
729 cat >"$expected" <<EOF
732 cat >`mhpath new` <<EOF
733 Date: Fri, 13 May 2011 08:21:12 -0500
734 Content-Type: multipart/alternative;
735 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
736 Content-Transfer-Encoding: 8bit
738 From: <sender@example.com>
739 To: <recipient@example.com>
740 Subject: mhfixmsg bad boundary test
742 This is a multi-part message in MIME format.
744 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
745 Content-Type: text/plain
747 The boundaries of this part don't match the header boundary.
749 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
752 cp -p `mhpath last` `mhpath new`
754 run_test
'mhfixmsg last -nofixboundary' ''
755 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
758 # check that message is not output when fed through stdin
759 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
760 check
"$expected" "$actual"
761 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
762 "$actual.err" >/dev
/null
; then
765 echo "$0: test failed, output is in $actual.err."
766 failed
=`expr ${failed:-0} + 1`
770 # check fixup of erroneous boundary in multipart (-fixboundary,
771 # enabled by default)
773 cat >"$expected" <<EOF
774 Date: Fri, 13 May 2011 08:21:12 -0500
775 Content-Type: multipart/alternative;
776 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
777 Content-Transfer-Encoding: 8bit
779 From: <sender@example.com>
780 To: <recipient@example.com>
781 Subject: mhfixmsg bad boundary test
783 This is a multi-part message in MIME format.
785 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
786 Content-Type: text/plain
788 The boundaries of this part don't match the header boundary.
790 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
793 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
794 "mhfixmsg: 17, fix multipart boundary"
795 check
"$expected" "$actual"
798 # check that text/plain part is not added to text/html in multipart/related
799 # when it shouldn't be
800 cat >`mhpath new` <<EOF
802 Date: Tue, 26 Feb 2013 18:07:20 -0600
803 Subject: multipart/related, not /alternative
804 Content-Type: multipart/related;
805 type="text/html"; boundary="----=_Part_90310_101292502.1"
807 ------=_Part_90310_101292502.1
808 Content-Type: text/html; charset="us-ascii"
809 Content-Transfer-Encoding: 7bit
812 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
813 <title>HTML Content</title>
816 This is the real content.
820 ------=_Part_90310_101292502.1
821 Content-Type: text/plain; charset="us-ascii"
822 Content-Transfer-Encoding: 7bit
824 Your email client does not support HTML messages
826 ------=_Part_90310_101292502.1--
829 cp -p `mhpath last` "$expected"
831 if [ $can_reformat_texthtml -eq 1 ]; then
832 #### lynx inserts multiple blank lines, so squeeze them.
833 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
834 check
"$expected" "$actual" 'ignore space'
840 # check handling of rfc822 message type
841 cat >"$expected" <<EOF
842 From: Test <test@example.com>
843 To: Some User <user@example.com>
844 Date: Fri, 29 Sep 2006 00:00:00
845 Message-Id: @test.nmh
846 Subject: message with message/rfc822 attachment
848 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
850 and some garbage before the attachment
852 ------- =_aaaaaaaaaa0
853 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
854 Content-Description: 1552
855 Content-Disposition: attachment; filename="1552"
857 From: Test <test@example.com>
858 To: <another_user@example.com>
859 Date: Thu, 28 Sep 2006 00:00:00
860 Message-Id: @test.nmh
861 Subject: message/rfc822 attachment
863 This is an RFC-822 message.
865 ------- =_aaaaaaaaaa0--
867 and some garbage at the end
870 cat >`mhpath new` <<EOF
871 From: Test <test@example.com>
872 To: Some User <user@example.com>
873 Date: Fri, 29 Sep 2006 00:00:00
874 Message-Id: @test.nmh
875 Subject: message with message/rfc822 attachment
877 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
879 and some garbage before the attachment
881 ------- =_aaaaaaaaaa0
882 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
883 Content-Description: 1552
884 Content-Disposition: attachment; filename="1552"
886 From: Test <test@example.com>
887 To: <another_user@example.com>
888 Date: Thu, 28 Sep 2006 00:00:00
889 Message-Id: @test.nmh
890 Subject: message/rfc822 attachment
892 This is an RFC-822 message.
894 ------- =_aaaaaaaaaa0--
896 and some garbage at the end
899 run_test
'mhfixmsg last -outfile '"$actual" ''
900 check
"$expected" "$actual"
903 # check stripping of CRs from ASCII text context
904 cat >"$expected" <<EOF
906 From: sender@example.com
907 To: recipient@example.com
908 Subject: message with CR's
909 Date: Mon, 29 Apr 2013 11:51:45 -0400
911 There are two CR-LF pairs at the end of this sentence.
915 cat >`mhpath new` <<'EOF'
917 From: sender@example.com
918 To: recipient@example.com
919 Subject: message with CR's
920 Date: Mon, 29 Apr 2013 11:51:45 -0400
922 There are two CR-LF pairs at the end of this sentence.
926 run_prog mhfixmsg last
-outfile "$actual"
927 check
"$expected" "$actual"
930 # check -replacetextplain
931 prepare_space
>"$expected" <<EOF
932 To: recipient@example.com
933 From: sender@example.com
934 Subject: mhfixmsg replacement of bad text/plain part test
936 Content-Type: multipart/alternative; boundary="----=_Part_876302"
939 Content-Type: text/plain; charset="UTF-8"
940 Content-Transfer-Encoding: 8bit
942 Yes, the text/plain part really was empty.
945 Content-Type: text/html; charset="UTF-8"
946 Content-Transfer-Encoding: 8bit
947 Content-Disposition: inline
950 <title>eticket</title>
953 Yes, the text/plain part really was empty.
957 ------=_Part_876302--
960 cat >`mhpath new` <<'EOF'
961 To: recipient@example.com
962 From: sender@example.com
963 Subject: mhfixmsg replacement of bad text/plain part test
965 Content-Type: multipart/alternative; boundary="----=_Part_876302"
968 Content-Type: text/plain; charset="iso-8859-15"
969 Content-Transfer-Encoding: 7bit
970 Content-Disposition: inline
975 Content-Type: text/html; charset="UTF-8"
976 Content-Transfer-Encoding: 8bit
977 Content-Disposition: inline
980 <title>eticket</title>
983 Yes, the text/plain part really was empty.
987 ------=_Part_876302--
990 if [ $can_reformat_texthtml -eq 1 ]; then
991 #### lynx inserts multiple blank lines, so squeeze them.
992 run_prog mhfixmsg last
-replacetextplain -outfile - | \
993 squeeze_lines
> "$actual"
994 check
"$expected" "$actual" 'ignore space'
1000 # check -noreplacetextplain
1001 cat >"$expected" <<EOF
1002 To: recipient@example.com
1003 From: sender@example.com
1004 Subject: mhfixmsg replacement of bad text/plain part test
1006 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1009 Content-Type: text/plain; charset="iso-8859-15"
1010 Content-Transfer-Encoding: 7bit
1011 Content-Disposition: inline
1016 Content-Type: text/html; charset="UTF-8"
1017 Content-Transfer-Encoding: 8bit
1018 Content-Disposition: inline
1021 <title>eticket</title>
1024 Yes, the text/plain part really was empty.
1028 ------=_Part_876302--
1031 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1032 check
"$expected" "$actual"
1035 # check removal of extraneous trailing semicolon from header parameter list
1036 cat >"$expected" <<EOF
1037 To: recipient@example.com
1039 From: sender@example.com
1041 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1043 ------- =_aaaaaaaaaa0
1044 Content-Type: text/plain; charset="us-ascii"
1048 ------- =_aaaaaaaaaa0
1049 Content-Type: text/plain; charset="us-ascii";
1051 Content-Description: check folded headers, with and without trailing semicolon
1052 Content-Disposition: attachment;
1057 ------- =_aaaaaaaaaa0--
1060 cat >`mhpath new` <<EOF
1061 To: recipient@example.com
1063 From: sender@example.com
1065 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1067 ------- =_aaaaaaaaaa0
1068 Content-Type: text/plain; charset="us-ascii";
1072 ------- =_aaaaaaaaaa0
1073 Content-Type: text/plain; charset="us-ascii";
1075 Content-Description: check folded headers, with and without trailing semicolon
1076 Content-Disposition: attachment;
1081 ------- =_aaaaaaaaaa0--
1083 run_test
'mhfixmsg last -outfile '"$actual" ''
1084 check
"$expected" "$actual"
1088 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1091 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1092 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1093 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1095 run_test
'mhfixmsg 15' ''
1096 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1097 "${MH_TEST_DIR}/Mail/inbox/15.original"
1101 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1103 run_test
'mhfixmsg 19 -normmproc'
1104 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1105 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1109 run_test
'mhfixmsg 20 -rmmproc true'
1110 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1111 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1112 failed
=`expr ${failed:-0} + 1`
1117 cat >"$expected" <<EOF
1118 To: recipient@example.com
1119 From: sender@example.com
1120 Subject: mhfixmsg with incorrect Content-Type
1122 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1124 ------- =_aaaaaaaaaa0
1125 Content-Type: text/plain; name="plaintext.txt"
1129 ------- =_aaaaaaaaaa0--
1132 cat >`mhpath new` <<EOF
1133 To: recipient@example.com
1134 From: sender@example.com
1135 Subject: mhfixmsg with incorrect Content-Type
1137 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1139 ------- =_aaaaaaaaaa0
1140 Content-Type: application/octet-stream; name="plaintext.txt"
1144 ------- =_aaaaaaaaaa0--
1147 mhfixmsg
-fixtype application
/octet
-stream last
1148 check
"$expected" `mhpath last`
1151 # make sure there are no tmp files left over
1152 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1154 cat >"$expected" <<EOF
1157 check
"$expected" "$actual"