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 # Verified same behavior as compiled mhfixmsg.
71 case `mhfixmsg -version` in
73 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
74 failed
=`expr ${failed:-0} + 1`;;
78 # check that non-MIME messages aren't modified
80 run_test
'mhfixmsg first -outfile '"$actual" ''
81 check
"`mhpath first`" "$actual" 'keep first'
84 # check that non-MIME messages with no bodies aren't modified
86 cat >`mhpath new` <<EOF
87 From: Test <test@example.com>
88 To: Some User <user@example.com>
89 Date: Fri, 29 Sep 2006 00:00:00
91 Subject: message with no body
94 run_test
'mhfixmsg last -outfile '"$actual" ''
95 check
"`mhpath last`" "$actual"
99 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
102 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
103 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
105 Content-Type: MULTIPART/MIXED;
106 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
107 Content-Transfer-Encoding: QUOTED-PRINTABLE
109 This message is in MIME format. The first part should be readable
111 while the remaining parts are likely unreadable without MIME-aware
114 ------=_NextPart_000_0000_00000000.00000000
115 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
116 Content-Transfer-Encoding: 8BIT
118 Some text in swedish.
120 Varf=C3=B6r inte anv=C3=A4nda...
122 ------=_NextPart_000_0000_00000000.00000000--
124 And some text after the last part.
127 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
129 run_test
'mhfixmsg last -nofixcte' ''
130 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
133 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
135 cat >"$expected" <<EOF
138 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
139 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
141 Content-Type: MULTIPART/MIXED;
142 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
143 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
144 Content-Transfer-Encoding: 8bit
146 This message is in MIME format. The first part should be readable
148 while the remaining parts are likely unreadable without MIME-aware
151 ------=_NextPart_000_0000_00000000.00000000
152 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
153 Content-Transfer-Encoding: 8BIT
155 Some text in swedish.
157 Varf=C3=B6r inte anv=C3=A4nda...
159 ------=_NextPart_000_0000_00000000.00000000--
161 And some text after the last part.
164 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
165 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
166 QUOTED-PRINTABLE with 8 bit"
167 check
"$expected" "$actual" 'keep first'
170 # check with no options: checks backup
171 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
172 folder last
>/dev
/null
173 run_test
'mhfixmsg' ''
174 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
175 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
176 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
179 # check backup with -file
180 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
181 folder last
>/dev
/null
182 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
183 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
184 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
187 # check -reformat (enabled by default): addition of text/plain part
188 # to solitary text/html part
190 prepare_space
>"$expected" <<EOF
192 From: sender@example.com
193 To: bonquiqui@example.com
195 Date: Sat, 26 Jan 2013 17:37:53 -0500
196 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
198 ------=_nmh-multipart
199 Content-Type: text/plain; charset="Windows-1252"
200 Content-Transfer-Encoding: 8bit
202 Need to go! Need ... to ... go!
204 ------=_nmh-multipart
205 Content-Type: text/html; charset="Windows-1252"
206 Content-Transfer-Encoding: 8bit
210 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
211 <meta name="Generator" content="Microsoft Exchange Server">
212 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
216 <div>Need to go! Need ... to ... go!</div>
220 ------=_nmh-multipart--
223 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
225 From: sender@example.com
226 To: bonquiqui@example.com
228 Date: Sat, 26 Jan 2013 17:37:53 -0500
229 Content-Type: text/html; charset="Windows-1252"
230 Content-Transfer-Encoding: quoted-printable
234 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
236 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
237 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
238 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
242 <div>Need to go! Need ... to ... go!</div>
247 if [ $can_reformat_texthtml -eq 1 ]; then
248 printf '%s\n' "mhfixmsg: 12, insert text/plain part
249 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
252 #### lynx inserts multiple blank lines, so squeeze them.
253 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
254 squeeze_lines
>"$actual"
255 check
"$expected" "$actual" 'ignore space'
256 check
"$expected.err" "$actual.err"
262 # check implicit -file with absolute pathname
263 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
266 # check handling of boundary string that appears in message body
268 prepare_space
>"$expected" <<EOF
270 From: sender@example.com
271 To: bonquiqui@example.com
273 Date: Sat, 26 Jan 2013 17:37:53 -0500
274 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
276 ------=_nmh-multipart-3
277 Content-Type: text/plain; charset="Windows-1252"
278 Content-Transfer-Encoding: 8bit
280 ------=_nmh-multipart
281 ------=_nmh-multipart-1
282 ------=_nmh-multipart-2
284 ------=_nmh-multipart-3
285 Content-Type: text/html; charset="Windows-1252"
286 Content-Transfer-Encoding: 8bit
290 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
291 <meta name="Generator" content="Microsoft Exchange Server">
292 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
295 ------=_nmh-multipart<br>
296 ------=_nmh-multipart-1<br>
297 ------=_nmh-multipart-2<br>
301 ------=_nmh-multipart-3--
304 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
306 From: sender@example.com
307 To: bonquiqui@example.com
309 Date: Sat, 26 Jan 2013 17:37:53 -0500
310 Content-Type: text/html; charset="Windows-1252"
311 Content-Transfer-Encoding: quoted-printable
315 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
317 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
318 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
319 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
322 ------=3D_nmh-multipart<br>
323 ------=3D_nmh-multipart-1<br>
324 ------=3D_nmh-multipart-2<br>
329 if [ $can_reformat_texthtml -eq 1 ]; then
330 printf '%s\n' "mhfixmsg: 12, insert text/plain part
331 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
334 #### lynx inserts multiple blank lines, so squeeze them.
335 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
336 squeeze_lines
>"$actual"
337 check
"$expected" "$actual" 'ignore space'
338 check
"$expected.err" "$actual.err"
345 prepare_space
>"$expected" <<EOF
347 From: sender@example.com
348 To: bonquiqui@example.com
350 Date: Sat, 26 Jan 2013 17:37:53 -0500
351 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
353 ------=_nmh-multipart
354 Content-Type: text/plain; charset="Windows-1252"
355 Content-Transfer-Encoding: 8bit
357 Need to go! Need ... to ... go!
359 ------=_nmh-multipart
360 Content-Type: text/html; charset="Windows-1252"
361 Content-Transfer-Encoding: quoted-printable
365 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
367 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
368 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
369 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
373 <div>Need to go! Need ... to ... go!</div>
377 ------=_nmh-multipart--
380 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
382 From: sender@example.com
383 To: bonquiqui@example.com
385 Date: Sat, 26 Jan 2013 17:37:53 -0500
386 Content-Type: text/html; charset="Windows-1252"
387 Content-Transfer-Encoding: quoted-printable
391 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
393 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
394 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
395 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
399 <div>Need to go! Need ... to ... go!</div>
404 if [ $can_reformat_texthtml -eq 1 ]; then
405 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
407 #### lynx inserts multiple blank lines, so squeeze them.
408 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
409 squeeze_lines
>"$actual"
410 check
"$expected" "$actual" 'ignore space'
411 check
"$expected.err" "$actual.err"
417 # check -decode (enabled by default)
418 cat >"$expected" <<EOF
419 To: recipient@example.com
420 From: sender@example.com
421 Subject: mhfixmsg decode test
423 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
425 ------- =_aaaaaaaaaa0
426 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
427 Content-Disposition: attachment; filename="test4.txt"
428 Content-Transfer-Encoding: 8bit
430 This is a text/plain part.
432 ------- =_aaaaaaaaaa0--
435 cat >`mhpath new` <<EOF
436 To: recipient@example.com
437 From: sender@example.com
438 Subject: mhfixmsg decode test
440 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
442 ------- =_aaaaaaaaaa0
443 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
444 Content-Disposition: attachment; filename="test4.txt"
445 Content-Transfer-Encoding: base64
447 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
449 ------- =_aaaaaaaaaa0--
452 run_prog mhfixmsg last
-outfile "$actual"
453 check
"$expected" "$actual"
456 # check -decode with more complicated content structure
458 To: recipient@example.com
459 From: sender@example.com
460 Subject: mhfixmsg decode test 2
462 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
464 This is additional content before the first subpart of the multipart.
466 ------- =_aaaaaaaaaa0
467 Content-Type: multipart/related;
468 type="text/plain"; 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="text/plain"; boundary="subpart__1.1"
520 Content-Type: text/plain; charset="iso-8859-1"
521 Content-Disposition: attachment; filename="test1.txt"
523 This is the first text/plain part, in a subpart.
527 This is additional content after the last subpart of the multipart.
529 ------- =_aaaaaaaaaa0
530 Content-Type: text/plain; charset="iso-8859-1"
531 Content-Disposition: attachment; filename="test2.txt"
532 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
533 Content-Transfer-Encoding: quoted-printable
535 This is the second text/plain part.
537 ------- =_aaaaaaaaaa0
538 Content-Type: text/plain; charset="iso-8859-1"
539 Content-Disposition: attachment; filename="test3.txt"
541 This is the third text/plain part.
543 ------- =_aaaaaaaaaa0
544 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
545 Content-Disposition: attachment; filename="test4.txt"
546 Content-Transfer-Encoding: base64
548 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
550 ------- =_aaaaaaaaaa0--
552 This is additional content after the last subpart of the multipart.
554 run_prog mhfixmsg last
-outfile "$actual"
555 check
"$expected" "$actual"
558 # check attempted -decode of binary text
559 #### Generated the encoded text below with:
560 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
561 cat >`mhpath new` <<EOF
562 To: recipient@example.com
563 From: sender@example.com
564 Subject: mhfixmsg attempted binary decode test
566 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
568 ------- =_aaaaaaaaaa0
569 Content-Type: text/plain; charset="iso-8859-1"; name="nul+square.txt"
570 Content-Transfer-Encoding: base64
574 ------- =_aaaaaaaaaa0--
577 cp -p `mhpath last` "$expected"
578 run_prog mhfixmsg last
579 check
`mhpath last` "$expected" 'keep first'
582 # check -decode of binary text
583 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
584 From: sender@example.com
585 Subject: mhfixmsg binary decode test
587 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
589 ------- =_aaaaaaaaaa0
590 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"nul+square.txt\"
591 Content-Transfer-Encoding: binary
595 ------- =_aaaaaaaaaa0--
597 ## output_content() in mhoutsbr.c can't handle binary content.
598 ## mhfixmsg last -decodetext binary -outfile "$actual"
599 ## check "$expected" "$actual"
604 # check that -reformat succeeds when decode of binary text fails
605 prepare_space
>"$expected" <<'EOF'
607 Date: Thu, 11 Apr 2013 02:47:08 -0700
609 From: <sender@example.com>
610 Subject: body requires binary encoding
611 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
613 ------=_nmh-multipart
614 Content-Type: text/plain; charset="ISO-8859-1"
615 Content-Transfer-Encoding: 8bit
620 Vehicle License Fee $1.84
623 ------=_nmh-multipart
624 Content-Type: text/html; charset="ISO-8859-1"
625 Content-Transfer-Encoding: quoted-printable
630 cat >`mhpath new` <<'EOF'
632 Content-Type: text/html; charset="ISO-8859-1"
633 Content-Transfer-Encoding: quoted-printable
634 Date: Thu, 11 Apr 2013 02:47:08 -0700
636 From: <sender@example.com>
637 Subject: body requires binary encoding
640 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
641 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
642 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
643 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
644 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
645 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
646 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
647 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
648 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
649 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
650 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
651 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
652 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
653 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
654 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
655 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
656 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
657 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
658 #333333" size=3D"2">$6.00</font></td></tr>
664 if [ $can_reformat_texthtml -eq 1 ]; then
665 #### lynx inserts multiple blank lines, so squeeze them.
666 #### Truncate to avoid comparing the html portion because it can
667 #### get reformatted.
668 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
669 check
"$expected" "$actual" 'ignore space'
671 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
677 # Also checks preservation of attributes after one (charset) that is
679 cat >"$expected" <<EOF
680 To: recipient@example.com
681 From: sender@example.com
682 Subject: mhfixmsg textcharset test
684 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
686 ------- =_aaaaaaaaaa0
687 Content-Type: text/plain; charset="utf-8"; name="square.txt"
688 Content-Disposition: attachment; filename="square.txt"
689 Content-Transfer-Encoding: 8bit
693 ------- =_aaaaaaaaaa0--
696 #### Generated the encoded text below with:
697 #### $ printf '\xbd\xb2=\xbc\n' | base64
698 cat >`mhpath new` <<EOF
699 To: recipient@example.com
700 From: sender@example.com
701 Subject: mhfixmsg textcharset test
703 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
705 ------- =_aaaaaaaaaa0
706 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
707 Content-Disposition: attachment; filename="square.txt"
708 Content-Transfer-Encoding: base64
712 ------- =_aaaaaaaaaa0--
715 if test "$ICONV_ENABLED" -eq 1; then
716 run_prog mhfixmsg last
-textcharset utf-8
-outfile "$actual" 2>&1
717 check
"$expected" "$actual"
719 echo "$0: skipping -textcharset check because nmh was built without iconv"
724 # check -nofixboundary
725 cat >"$expected" <<EOF
728 cat >`mhpath new` <<EOF
729 Date: Fri, 13 May 2011 08:21:12 -0500
730 Content-Type: multipart/alternative;
731 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
732 Content-Transfer-Encoding: 8bit
734 From: <sender@example.com>
735 To: <recipient@example.com>
736 Subject: mhfixmsg bad boundary test
738 This is a multi-part message in MIME format.
740 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
741 Content-Type: text/plain
743 The boundaries of this part don't match the header boundary.
745 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
748 cp -p `mhpath last` `mhpath new`
750 run_test
'mhfixmsg last -nofixboundary' ''
751 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
754 # check that message is not output when fed through stdin
755 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
756 check
"$expected" "$actual"
757 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
758 "$actual.err" >/dev
/null
; then
761 echo "$0: test failed, output is in $actual.err."
762 failed
=`expr ${failed:-0} + 1`
766 # check fixup of erroneous boundary in multipart (-fixboundary,
767 # enabled by default)
769 cat >"$expected" <<EOF
770 Date: Fri, 13 May 2011 08:21:12 -0500
771 Content-Type: multipart/alternative;
772 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
773 Content-Transfer-Encoding: 8bit
775 From: <sender@example.com>
776 To: <recipient@example.com>
777 Subject: mhfixmsg bad boundary test
779 This is a multi-part message in MIME format.
781 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
782 Content-Type: text/plain
784 The boundaries of this part don't match the header boundary.
786 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
789 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
790 "mhfixmsg: 17, fix multipart boundary"
791 check
"$expected" "$actual"
794 # check that text/plain part is not added to text/html in multipart/related
795 # when it shouldn't be
796 cat >`mhpath new` <<EOF
798 Date: Tue, 26 Feb 2013 18:07:20 -0600
799 Subject: multipart/related, not /alternative
800 Content-Type: multipart/related;
801 type="text/html"; boundary="----=_Part_90310_101292502.1"
803 ------=_Part_90310_101292502.1
804 Content-Type: text/html; charset="us-ascii"
805 Content-Transfer-Encoding: 7bit
808 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
809 <title>HTML Content</title>
812 This is the real content.
816 ------=_Part_90310_101292502.1
817 Content-Type: text/plain; charset="us-ascii"
818 Content-Transfer-Encoding: 7bit
820 Your email client does not support HTML messages
822 ------=_Part_90310_101292502.1--
825 cp -p `mhpath last` "$expected"
827 if [ $can_reformat_texthtml -eq 1 ]; then
828 #### lynx inserts multiple blank lines, so squeeze them.
829 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
830 check
"$expected" "$actual" 'ignore space'
836 # check handling of rfc822 message type
837 cat >"$expected" <<EOF
838 From: Test <test@example.com>
839 To: Some User <user@example.com>
840 Date: Fri, 29 Sep 2006 00:00:00
841 Message-Id: @test.nmh
842 Subject: message with message/rfc822 attachment
844 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
846 and some garbage before the attachment
848 ------- =_aaaaaaaaaa0
849 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
850 Content-Description: 1552
851 Content-Disposition: attachment; filename="1552"
853 From: Test <test@example.com>
854 To: <another_user@example.com>
855 Date: Thu, 28 Sep 2006 00:00:00
856 Message-Id: @test.nmh
857 Subject: message/rfc822 attachment
859 This is an RFC-822 message.
861 ------- =_aaaaaaaaaa0--
863 and some garbage at the end
866 cat >`mhpath new` <<EOF
867 From: Test <test@example.com>
868 To: Some User <user@example.com>
869 Date: Fri, 29 Sep 2006 00:00:00
870 Message-Id: @test.nmh
871 Subject: message with message/rfc822 attachment
873 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
875 and some garbage before the attachment
877 ------- =_aaaaaaaaaa0
878 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
879 Content-Description: 1552
880 Content-Disposition: attachment; filename="1552"
882 From: Test <test@example.com>
883 To: <another_user@example.com>
884 Date: Thu, 28 Sep 2006 00:00:00
885 Message-Id: @test.nmh
886 Subject: message/rfc822 attachment
888 This is an RFC-822 message.
890 ------- =_aaaaaaaaaa0--
892 and some garbage at the end
895 run_test
'mhfixmsg last -outfile '"$actual" ''
896 check
"$expected" "$actual"
899 # check stripping of CRs from ASCII text context
900 cat >"$expected" <<EOF
902 From: sender@example.com
903 To: recipient@example.com
904 Subject: message with CR's
905 Date: Mon, 29 Apr 2013 11:51:45 -0400
907 There are two CR-LF pairs at the end of this sentence.
911 cat >`mhpath new` <<'EOF'
913 From: sender@example.com
914 To: recipient@example.com
915 Subject: message with CR's
916 Date: Mon, 29 Apr 2013 11:51:45 -0400
918 There are two CR-LF pairs at the end of this sentence.
922 run_prog mhfixmsg last
-outfile "$actual"
923 check
"$expected" "$actual"
926 # check -replacetextplain
927 prepare_space
>"$expected" <<EOF
928 To: recipient@example.com
929 From: sender@example.com
930 Subject: mhfixmsg replacement of bad text/plain part test
932 Content-Type: multipart/alternative; boundary="----=_Part_876302"
935 Content-Type: text/plain; charset="UTF-8"
936 Content-Transfer-Encoding: 8bit
938 Yes, the text/plain part really was empty.
941 Content-Type: text/html; charset="UTF-8"
942 Content-Transfer-Encoding: 8bit
943 Content-Disposition: inline
946 <title>eticket</title>
949 Yes, the text/plain part really was empty.
953 ------=_Part_876302--
956 cat >`mhpath new` <<'EOF'
957 To: recipient@example.com
958 From: sender@example.com
959 Subject: mhfixmsg replacement of bad text/plain part test
961 Content-Type: multipart/alternative; boundary="----=_Part_876302"
964 Content-Type: text/plain; charset="iso-8859-15"
965 Content-Transfer-Encoding: 7bit
966 Content-Disposition: inline
971 Content-Type: text/html; charset="UTF-8"
972 Content-Transfer-Encoding: 8bit
973 Content-Disposition: inline
976 <title>eticket</title>
979 Yes, the text/plain part really was empty.
983 ------=_Part_876302--
986 if [ $can_reformat_texthtml -eq 1 ]; then
987 #### lynx inserts multiple blank lines, so squeeze them.
988 run_prog mhfixmsg last
-replacetextplain -outfile - | \
989 squeeze_lines
> "$actual"
990 check
"$expected" "$actual" 'ignore space'
996 # check -noreplacetextplain
997 cat >"$expected" <<EOF
998 To: recipient@example.com
999 From: sender@example.com
1000 Subject: mhfixmsg replacement of bad text/plain part test
1002 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1005 Content-Type: text/plain; charset="iso-8859-15"
1006 Content-Transfer-Encoding: 7bit
1007 Content-Disposition: inline
1012 Content-Type: text/html; charset="UTF-8"
1013 Content-Transfer-Encoding: 8bit
1014 Content-Disposition: inline
1017 <title>eticket</title>
1020 Yes, the text/plain part really was empty.
1024 ------=_Part_876302--
1027 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1028 check
"$expected" "$actual"
1031 # check removal of extraneous trailing semicolon from header parameter list
1032 cat >"$expected" <<EOF
1033 To: recipient@example.com
1035 From: sender@example.com
1037 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1039 ------- =_aaaaaaaaaa0
1040 Content-Type: text/plain; charset="us-ascii"
1044 ------- =_aaaaaaaaaa0
1045 Content-Type: text/plain; charset="us-ascii";
1047 Content-Description: check folded headers, with and without trailing semicolon
1048 Content-Disposition: attachment;
1053 ------- =_aaaaaaaaaa0--
1056 cat >`mhpath new` <<EOF
1057 To: recipient@example.com
1059 From: sender@example.com
1061 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1063 ------- =_aaaaaaaaaa0
1064 Content-Type: text/plain; charset="us-ascii";
1068 ------- =_aaaaaaaaaa0
1069 Content-Type: text/plain; charset="us-ascii";
1071 Content-Description: check folded headers, with and without trailing semicolon
1072 Content-Disposition: attachment;
1077 ------- =_aaaaaaaaaa0--
1079 run_test
'mhfixmsg last -outfile '"$actual" ''
1080 check
"$expected" "$actual"
1084 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1087 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1088 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1089 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1091 run_test
'mhfixmsg 15' ''
1092 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1093 "${MH_TEST_DIR}/Mail/inbox/15.original"
1097 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1099 run_test
'mhfixmsg 19 -normmproc'
1100 check
"${MH_TEST_DIR}/Mail/inbox/20" \
1101 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1105 run_test
'mhfixmsg 20 -rmmproc true'
1106 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1107 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1108 failed
=`expr ${failed:-0} + 1`
1112 # make sure there are no tmp files left over
1113 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1115 cat >"$expected" <<EOF
1118 check
"$expected" "$actual"