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 cat >"$expected" <<EOF
46 Usage: mhfixmsg [+folder] [msgs] [switches]
65 run_prog mhfixmsg
-help >"$actual" 2>&1
66 check
"$expected" "$actual"
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="text/plain"; boundary="subpart__1.1"
470 Content-Type: text/plain; charset="iso-8859-1"
471 Content-Disposition: attachment; filename="test1.txt"
473 This is the first text/plain part, in a subpart.
477 This is additional content after the last subpart of the multipart.
479 ------- =_aaaaaaaaaa0
480 Content-Type: text/plain; charset="iso-8859-1"
481 Content-Disposition: attachment; filename="test2.txt"
482 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
483 Content-Transfer-Encoding: 8bit
485 This is the second text/plain part.
487 ------- =_aaaaaaaaaa0
488 Content-Type: text/plain; charset="iso-8859-1"
489 Content-Disposition: attachment; filename="test3.txt"
491 This is the third text/plain part.
493 ------- =_aaaaaaaaaa0
494 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
495 Content-Disposition: attachment; filename="test4.txt"
496 Content-Transfer-Encoding: 8bit
498 This is the fourth text/plain part.
500 ------- =_aaaaaaaaaa0--
502 This is additional content after the last subpart of the multipart.
505 cat >`mhpath new` <<EOF
506 To: recipient@example.com
507 From: sender@example.com
508 Subject: mhfixmsg decode test 2
510 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
512 This is additional content before the first subpart of the multipart.
514 ------- =_aaaaaaaaaa0
515 Content-Type: multipart/related;
516 type="text/plain"; boundary="subpart__1.1"
519 Content-Type: text/plain; charset="iso-8859-1"
520 Content-Disposition: attachment; filename="test1.txt"
522 This is the first text/plain part, in a subpart.
526 This is additional content after the last subpart of the multipart.
528 ------- =_aaaaaaaaaa0
529 Content-Type: text/plain; charset="iso-8859-1"
530 Content-Disposition: attachment; filename="test2.txt"
531 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
532 Content-Transfer-Encoding: quoted-printable
534 This is the second text/plain part.
536 ------- =_aaaaaaaaaa0
537 Content-Type: text/plain; charset="iso-8859-1"
538 Content-Disposition: attachment; filename="test3.txt"
540 This is the third text/plain part.
542 ------- =_aaaaaaaaaa0
543 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
544 Content-Disposition: attachment; filename="test4.txt"
545 Content-Transfer-Encoding: base64
547 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
549 ------- =_aaaaaaaaaa0--
551 This is additional content after the last subpart of the multipart.
553 run_prog mhfixmsg last
-outfile "$actual"
554 check
"$expected" "$actual"
557 # check attempted -decode of binary text
558 #### Generated the encoded text below with:
559 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
560 cat >`mhpath new` <<EOF
561 To: recipient@example.com
562 From: sender@example.com
563 Subject: mhfixmsg attempted binary decode test
565 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
567 ------- =_aaaaaaaaaa0
568 Content-Type: text/plain; charset="iso-8859-1"; name="nul+square.txt"
569 Content-Transfer-Encoding: base64
573 ------- =_aaaaaaaaaa0--
576 cp -p `mhpath last` "$expected"
577 run_prog mhfixmsg last
578 check
`mhpath last` "$expected" 'keep first'
581 # check -decode of binary text
582 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
583 From: sender@example.com
584 Subject: mhfixmsg binary decode test
586 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
588 ------- =_aaaaaaaaaa0
589 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"nul+square.txt\"
590 Content-Transfer-Encoding: binary
594 ------- =_aaaaaaaaaa0--
596 ## output_content() in mhoutsbr.c can't handle binary content.
597 ## mhfixmsg last -decodetext binary -outfile "$actual"
598 ## check "$expected" "$actual"
603 # check that -reformat succeeds when decode of binary text fails
604 prepare_space
>"$expected" <<'EOF'
606 Date: Thu, 11 Apr 2013 02:47:08 -0700
608 From: <sender@example.com>
609 Subject: body requires binary encoding
610 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
612 ------=_nmh-multipart
613 Content-Type: text/plain; charset="ISO-8859-1"
614 Content-Transfer-Encoding: 8bit
619 Vehicle License Fee $1.84
622 ------=_nmh-multipart
623 Content-Type: text/html; charset="ISO-8859-1"
624 Content-Transfer-Encoding: quoted-printable
629 cat >`mhpath new` <<'EOF'
631 Content-Type: text/html; charset="ISO-8859-1"
632 Content-Transfer-Encoding: quoted-printable
633 Date: Thu, 11 Apr 2013 02:47:08 -0700
635 From: <sender@example.com>
636 Subject: body requires binary encoding
639 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
640 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
641 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
642 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
643 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
644 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
645 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
646 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
647 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
648 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
649 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
650 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
651 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
652 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
653 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
654 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
655 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
656 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
657 #333333" size=3D"2">$6.00</font></td></tr>
663 if [ $can_reformat_texthtml -eq 1 ]; then
664 #### lynx inserts multiple blank lines, so squeeze them.
665 #### Truncate to avoid comparing the html portion because it can
666 #### get reformatted.
667 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
668 check
"$expected" "$actual" 'ignore space'
670 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
676 # Also checks preservation of attributes after one (charset) that is
678 cat >"$expected" <<EOF
679 To: recipient@example.com
680 From: sender@example.com
681 Subject: mhfixmsg textcharset test
683 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
685 ------- =_aaaaaaaaaa0
686 Content-Type: text/plain; charset="utf-8"; name="square.txt"
687 Content-Disposition: attachment; filename="square.txt"
688 Content-Transfer-Encoding: 8bit
692 ------- =_aaaaaaaaaa0--
695 #### Generated the encoded text below with:
696 #### $ printf '\xbd\xb2=\xbc\n' | base64
697 cat >`mhpath new` <<EOF
698 To: recipient@example.com
699 From: sender@example.com
700 Subject: mhfixmsg textcharset test
702 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
704 ------- =_aaaaaaaaaa0
705 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
706 Content-Disposition: attachment; filename="square.txt"
707 Content-Transfer-Encoding: base64
711 ------- =_aaaaaaaaaa0--
714 if test "$ICONV_ENABLED" -eq 1; then
715 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
716 check
"$expected" "$actual"
718 echo "$0: skipping -textcharset check because nmh was built without iconv"
723 # check -nofixboundary
724 cat >"$expected" <<EOF
727 cat >`mhpath new` <<EOF
728 Date: Fri, 13 May 2011 08:21:12 -0500
729 Content-Type: multipart/alternative;
730 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
731 Content-Transfer-Encoding: 8bit
733 From: <sender@example.com>
734 To: <recipient@example.com>
735 Subject: mhfixmsg bad boundary test
737 This is a multi-part message in MIME format.
739 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
740 Content-Type: text/plain
742 The boundaries of this part don't match the header boundary.
744 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
747 cp -p `mhpath last` `mhpath new`
749 run_test
'mhfixmsg last -nofixboundary' ''
750 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
753 # check that message is not output when fed through stdin
754 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
755 check
"$expected" "$actual"
756 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
757 "$actual.err" >/dev
/null
; then
760 echo "$0: test failed, output is in $actual.err."
761 failed
=`expr ${failed:-0} + 1`
765 # check fixup of erroneous boundary in multipart (-fixboundary,
766 # enabled by default)
768 cat >"$expected" <<EOF
769 Date: Fri, 13 May 2011 08:21:12 -0500
770 Content-Type: multipart/alternative;
771 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
772 Content-Transfer-Encoding: 8bit
774 From: <sender@example.com>
775 To: <recipient@example.com>
776 Subject: mhfixmsg bad boundary test
778 This is a multi-part message in MIME format.
780 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
781 Content-Type: text/plain
783 The boundaries of this part don't match the header boundary.
785 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
788 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
789 "mhfixmsg: 17, fix multipart boundary"
790 check
"$expected" "$actual"
793 # check that text/plain part is not added to text/html in multipart/related
794 # when it shouldn't be
795 cat >`mhpath new` <<EOF
797 Date: Tue, 26 Feb 2013 18:07:20 -0600
798 Subject: multipart/related, not /alternative
799 Content-Type: multipart/related;
800 type="text/html"; boundary="----=_Part_90310_101292502.1"
802 ------=_Part_90310_101292502.1
803 Content-Type: text/html; charset="us-ascii"
804 Content-Transfer-Encoding: 7bit
807 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
808 <title>HTML Content</title>
811 This is the real content.
815 ------=_Part_90310_101292502.1
816 Content-Type: text/plain; charset="us-ascii"
817 Content-Transfer-Encoding: 7bit
819 Your email client does not support HTML messages
821 ------=_Part_90310_101292502.1--
824 cp -p `mhpath last` "$expected"
826 if [ $can_reformat_texthtml -eq 1 ]; then
827 #### lynx inserts multiple blank lines, so squeeze them.
828 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
829 check
"$expected" "$actual" 'ignore space'
835 # check handling of rfc822 message type
836 cat >"$expected" <<EOF
837 From: Test <test@example.com>
838 To: Some User <user@example.com>
839 Date: Fri, 29 Sep 2006 00:00:00
840 Message-Id: @test.nmh
841 Subject: message with message/rfc822 attachment
843 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
845 and some garbage before the attachment
847 ------- =_aaaaaaaaaa0
848 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
849 Content-Description: 1552
850 Content-Disposition: attachment; filename="1552"
852 From: Test <test@example.com>
853 To: <another_user@example.com>
854 Date: Thu, 28 Sep 2006 00:00:00
855 Message-Id: @test.nmh
856 Subject: message/rfc822 attachment
858 This is an RFC-822 message.
860 ------- =_aaaaaaaaaa0--
862 and some garbage at the end
865 cat >`mhpath new` <<EOF
866 From: Test <test@example.com>
867 To: Some User <user@example.com>
868 Date: Fri, 29 Sep 2006 00:00:00
869 Message-Id: @test.nmh
870 Subject: message with message/rfc822 attachment
872 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
874 and some garbage before the attachment
876 ------- =_aaaaaaaaaa0
877 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
878 Content-Description: 1552
879 Content-Disposition: attachment; filename="1552"
881 From: Test <test@example.com>
882 To: <another_user@example.com>
883 Date: Thu, 28 Sep 2006 00:00:00
884 Message-Id: @test.nmh
885 Subject: message/rfc822 attachment
887 This is an RFC-822 message.
889 ------- =_aaaaaaaaaa0--
891 and some garbage at the end
894 run_test
'mhfixmsg last -outfile '"$actual" ''
895 check
"$expected" "$actual"
898 # check stripping of CRs from ASCII text context
899 cat >"$expected" <<EOF
901 From: sender@example.com
902 To: recipient@example.com
903 Subject: message with CR's
904 Date: Mon, 29 Apr 2013 11:51:45 -0400
906 There are two CR-LF pairs at the end of this sentence.
910 cat >`mhpath new` <<'EOF'
912 From: sender@example.com
913 To: recipient@example.com
914 Subject: message with CR's
915 Date: Mon, 29 Apr 2013 11:51:45 -0400
917 There are two CR-LF pairs at the end of this sentence.
921 run_prog mhfixmsg last
-outfile "$actual"
922 check
"$expected" "$actual"
925 # check -replacetextplain
926 prepare_space
>"$expected" <<EOF
927 To: recipient@example.com
928 From: sender@example.com
929 Subject: mhfixmsg replacement of bad text/plain part test
931 Content-Type: multipart/alternative; boundary="----=_Part_876302"
934 Content-Type: text/plain; charset="UTF-8"
935 Content-Transfer-Encoding: 8bit
937 Yes, the text/plain part really was empty.
940 Content-Type: text/html; charset="UTF-8"
941 Content-Transfer-Encoding: 8bit
942 Content-Disposition: inline
945 <title>eticket</title>
948 Yes, the text/plain part really was empty.
952 ------=_Part_876302--
955 cat >`mhpath new` <<'EOF'
956 To: recipient@example.com
957 From: sender@example.com
958 Subject: mhfixmsg replacement of bad text/plain part test
960 Content-Type: multipart/alternative; boundary="----=_Part_876302"
963 Content-Type: text/plain; charset="iso-8859-15"
964 Content-Transfer-Encoding: 7bit
965 Content-Disposition: inline
970 Content-Type: text/html; charset="UTF-8"
971 Content-Transfer-Encoding: 8bit
972 Content-Disposition: inline
975 <title>eticket</title>
978 Yes, the text/plain part really was empty.
982 ------=_Part_876302--
985 if [ $can_reformat_texthtml -eq 1 ]; then
986 #### lynx inserts multiple blank lines, so squeeze them.
987 run_prog mhfixmsg last
-replacetextplain -outfile - | \
988 squeeze_lines
> "$actual"
989 check
"$expected" "$actual" 'ignore space'
995 # check -noreplacetextplain
996 cat >"$expected" <<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 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1027 check
"$expected" "$actual"
1030 # check removal of extraneous trailing semicolon from header parameter list
1031 cat >"$expected" <<EOF
1032 To: recipient@example.com
1034 From: sender@example.com
1036 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1038 ------- =_aaaaaaaaaa0
1039 Content-Type: text/plain; charset="us-ascii"
1043 ------- =_aaaaaaaaaa0
1044 Content-Type: text/plain; charset="us-ascii";
1046 Content-Description: check folded headers, with and without trailing semicolon
1047 Content-Disposition: attachment;
1052 ------- =_aaaaaaaaaa0--
1055 cat >`mhpath new` <<EOF
1056 To: recipient@example.com
1058 From: sender@example.com
1060 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1062 ------- =_aaaaaaaaaa0
1063 Content-Type: text/plain; charset="us-ascii";
1067 ------- =_aaaaaaaaaa0
1068 Content-Type: text/plain; charset="us-ascii";
1070 Content-Description: check folded headers, with and without trailing semicolon
1071 Content-Disposition: attachment;
1076 ------- =_aaaaaaaaaa0--
1078 run_test
'mhfixmsg last -outfile '"$actual" ''
1079 check
"$expected" "$actual"
1083 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1086 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1087 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1088 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1090 run_test
'mhfixmsg 15' ''
1091 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1092 "${MH_TEST_DIR}/Mail/inbox/15.original"
1096 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1098 run_test
'mhfixmsg 19 -normmproc'
1099 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1100 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1104 run_test
'mhfixmsg 20 -rmmproc true'
1105 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1106 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1107 failed
=`expr ${failed:-0} + 1`
1111 # make sure there are no tmp files left over
1112 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1114 cat >"$expected" <<EOF
1117 check
"$expected" "$actual"