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]
72 run_prog mhfixmsg
-help >"$actual" 2>&1
73 check
"$expected" "$actual"
77 case `mhfixmsg -version` in
79 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
80 failed
=`expr ${failed:-0} + 1`;;
84 # check that non-MIME messages aren't modified
86 run_test
'mhfixmsg first -outfile '"$actual" ''
87 check
"`mhpath first`" "$actual" 'keep first'
90 # check that non-MIME messages with no bodies aren't modified
92 cat >`mhpath new` <<EOF
93 From: Test <test@example.com>
94 To: Some User <user@example.com>
95 Date: Fri, 29 Sep 2006 00:00:00
97 Subject: message with no body
100 run_test
'mhfixmsg last -outfile '"$actual" ''
101 check
"`mhpath last`" "$actual"
105 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
108 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
109 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
111 Content-Type: MULTIPART/MIXED;
112 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
113 Content-Transfer-Encoding: QUOTED-PRINTABLE
115 This message is in MIME format. The first part should be readable
117 while the remaining parts are likely unreadable without MIME-aware
120 ------=_NextPart_000_0000_00000000.00000000
121 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
122 Content-Transfer-Encoding: 8BIT
124 Some text in swedish.
126 Varf=C3=B6r inte anv=C3=A4nda...
128 ------=_NextPart_000_0000_00000000.00000000--
130 And some text after the last part.
133 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
135 run_test
'mhfixmsg last -nofixcte' ''
136 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
139 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
141 cat >"$expected" <<EOF
144 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
145 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
147 Content-Type: MULTIPART/MIXED;
148 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
149 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
150 Content-Transfer-Encoding: 8bit
152 This message is in MIME format. The first part should be readable
154 while the remaining parts are likely unreadable without MIME-aware
157 ------=_NextPart_000_0000_00000000.00000000
158 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
159 Content-Transfer-Encoding: 8BIT
161 Some text in swedish.
163 Varf=C3=B6r inte anv=C3=A4nda...
165 ------=_NextPart_000_0000_00000000.00000000--
167 And some text after the last part.
170 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
171 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
172 QUOTED-PRINTABLE with 8 bit"
173 check
"$expected" "$actual" 'keep first'
176 # check with no options: checks backup
177 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
178 folder last
>/dev
/null
179 run_test
'mhfixmsg' ''
180 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
181 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
182 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
185 # check backup with -file
186 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
187 folder last
>/dev
/null
188 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
189 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
190 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
193 # check -reformat (enabled by default): addition of text/plain part
194 # to solitary text/html part
196 prepare_space
>"$expected" <<EOF
198 From: sender@example.com
199 To: bonquiqui@example.com
201 Date: Sat, 26 Jan 2013 17:37:53 -0500
202 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
204 ------=_nmh-multipart
205 Content-Type: text/plain; charset="Windows-1252"
206 Content-Transfer-Encoding: 8bit
208 Need to go! Need ... to ... go!
210 ------=_nmh-multipart
211 Content-Type: text/html; charset="Windows-1252"
212 Content-Transfer-Encoding: 8bit
216 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
217 <meta name="Generator" content="Microsoft Exchange Server">
218 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
222 <div>Need to go! Need ... to ... go!</div>
226 ------=_nmh-multipart--
229 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
231 From: sender@example.com
232 To: bonquiqui@example.com
234 Date: Sat, 26 Jan 2013 17:37:53 -0500
235 Content-Type: text/html; charset="Windows-1252"
236 Content-Transfer-Encoding: quoted-printable
240 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
242 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
243 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
244 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
248 <div>Need to go! Need ... to ... go!</div>
253 if [ $can_reformat_texthtml -eq 1 ]; then
254 printf '%s\n' "mhfixmsg: 12, insert text/plain part
255 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
258 #### lynx inserts multiple blank lines, so squeeze them.
259 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
260 squeeze_lines
>"$actual"
261 check
"$expected" "$actual" 'ignore space'
262 check
"$expected.err" "$actual.err"
268 # check implicit -file with absolute pathname
269 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
272 # check handling of boundary string that appears in message body
274 prepare_space
>"$expected" <<EOF
276 From: sender@example.com
277 To: bonquiqui@example.com
279 Date: Sat, 26 Jan 2013 17:37:53 -0500
280 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
282 ------=_nmh-multipart-3
283 Content-Type: text/plain; charset="Windows-1252"
284 Content-Transfer-Encoding: 8bit
286 ------=_nmh-multipart
287 ------=_nmh-multipart-1
288 ------=_nmh-multipart-2
290 ------=_nmh-multipart-3
291 Content-Type: text/html; charset="Windows-1252"
292 Content-Transfer-Encoding: 8bit
296 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
297 <meta name="Generator" content="Microsoft Exchange Server">
298 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
301 ------=_nmh-multipart<br>
302 ------=_nmh-multipart-1<br>
303 ------=_nmh-multipart-2<br>
307 ------=_nmh-multipart-3--
310 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
312 From: sender@example.com
313 To: bonquiqui@example.com
315 Date: Sat, 26 Jan 2013 17:37:53 -0500
316 Content-Type: text/html; charset="Windows-1252"
317 Content-Transfer-Encoding: quoted-printable
321 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
323 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
324 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
325 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
328 ------=3D_nmh-multipart<br>
329 ------=3D_nmh-multipart-1<br>
330 ------=3D_nmh-multipart-2<br>
335 if [ $can_reformat_texthtml -eq 1 ]; then
336 printf '%s\n' "mhfixmsg: 12, insert text/plain part
337 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
340 #### lynx inserts multiple blank lines, so squeeze them.
341 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
342 squeeze_lines
>"$actual"
343 check
"$expected" "$actual" 'ignore space'
344 check
"$expected.err" "$actual.err"
351 prepare_space
>"$expected" <<EOF
353 From: sender@example.com
354 To: bonquiqui@example.com
356 Date: Sat, 26 Jan 2013 17:37:53 -0500
357 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
359 ------=_nmh-multipart
360 Content-Type: text/plain; charset="Windows-1252"
361 Content-Transfer-Encoding: 8bit
363 Need to go! Need ... to ... go!
365 ------=_nmh-multipart
366 Content-Type: text/html; charset="Windows-1252"
367 Content-Transfer-Encoding: quoted-printable
371 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
373 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
374 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
375 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
379 <div>Need to go! Need ... to ... go!</div>
383 ------=_nmh-multipart--
386 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
388 From: sender@example.com
389 To: bonquiqui@example.com
391 Date: Sat, 26 Jan 2013 17:37:53 -0500
392 Content-Type: text/html; charset="Windows-1252"
393 Content-Transfer-Encoding: quoted-printable
397 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
399 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
400 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
401 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
405 <div>Need to go! Need ... to ... go!</div>
410 if [ $can_reformat_texthtml -eq 1 ]; then
411 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
413 #### lynx inserts multiple blank lines, so squeeze them.
414 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
415 squeeze_lines
>"$actual"
416 check
"$expected" "$actual" 'ignore space'
417 check
"$expected.err" "$actual.err"
423 # check -decodetext (enabled by default)
424 cat >"$expected" <<EOF
425 To: recipient@example.com
426 From: sender@example.com
427 Subject: mhfixmsg decode test 1
429 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
431 ------- =_aaaaaaaaaa0
432 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
433 Content-Disposition: attachment; filename="test4.txt"
434 Content-Transfer-Encoding: 8bit
436 This is a text/plain part.
438 ------- =_aaaaaaaaaa0--
441 cat >`mhpath new` <<EOF
442 To: recipient@example.com
443 From: sender@example.com
444 Subject: mhfixmsg decode test 1
446 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
448 ------- =_aaaaaaaaaa0
449 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
450 Content-Disposition: attachment; filename="test4.txt"
451 Content-Transfer-Encoding: base64
453 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
455 ------- =_aaaaaaaaaa0--
458 run_prog mhfixmsg last
-outfile "$actual"
459 check
"$expected" "$actual"
462 # check -decodetext with more complicated content structure
464 To: recipient@example.com
465 From: sender@example.com
466 Subject: mhfixmsg decode test 2
468 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
470 This is additional content before the first subpart of the multipart.
472 ------- =_aaaaaaaaaa0
473 Content-Type: multipart/related;
474 type="text/plain"; boundary="subpart__1.1"
477 Content-Type: text/plain; charset="iso-8859-1"
478 Content-Disposition: attachment; filename="test1.txt"
480 This is the first text/plain part, in a subpart.
484 This is additional content after the last subpart of the multipart.
486 ------- =_aaaaaaaaaa0
487 Content-Type: text/plain; charset="iso-8859-1"
488 Content-Disposition: attachment; filename="test2.txt"
489 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
490 Content-Transfer-Encoding: 8bit
492 This is the second text/plain part.
494 ------- =_aaaaaaaaaa0
495 Content-Type: text/plain; charset="iso-8859-1"
496 Content-Disposition: attachment; filename="test3.txt"
498 This is the third text/plain part.
500 ------- =_aaaaaaaaaa0
501 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
502 Content-Disposition: attachment; filename="test4.txt"
503 Content-Transfer-Encoding: 8bit
505 This is the fourth text/plain part.
507 ------- =_aaaaaaaaaa0--
509 This is additional content after the last subpart of the multipart.
512 cat >`mhpath new` <<EOF
513 To: recipient@example.com
514 From: sender@example.com
515 Subject: mhfixmsg decode test 2
517 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
519 This is additional content before the first subpart of the multipart.
521 ------- =_aaaaaaaaaa0
522 Content-Type: multipart/related;
523 type="text/plain"; boundary="subpart__1.1"
526 Content-Type: text/plain; charset="iso-8859-1"
527 Content-Disposition: attachment; filename="test1.txt"
529 This is the first text/plain part, in a subpart.
533 This is additional content after the last subpart of the multipart.
535 ------- =_aaaaaaaaaa0
536 Content-Type: text/plain; charset="iso-8859-1"
537 Content-Disposition: attachment; filename="test2.txt"
538 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
539 Content-Transfer-Encoding: quoted-printable
541 This is the second text/plain part.
543 ------- =_aaaaaaaaaa0
544 Content-Type: text/plain; charset="iso-8859-1"
545 Content-Disposition: attachment; filename="test3.txt"
547 This is the third text/plain part.
549 ------- =_aaaaaaaaaa0
550 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
551 Content-Disposition: attachment; filename="test4.txt"
552 Content-Transfer-Encoding: base64
554 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
556 ------- =_aaaaaaaaaa0--
558 This is additional content after the last subpart of the multipart.
560 run_prog mhfixmsg last
-outfile "$actual"
561 check
"$expected" "$actual"
564 # check attempted -decodetext of binary text
565 #### Generated the encoded text below with:
566 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
567 cat >`mhpath new` <<EOF
568 To: recipient@example.com
569 From: sender@example.com
570 Subject: mhfixmsg attempted binary decode test
572 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
574 ------- =_aaaaaaaaaa0
575 Content-Type: text/plain; charset="iso-8859-1"; name="nul+square.txt"
576 Content-Transfer-Encoding: base64
580 ------- =_aaaaaaaaaa0--
583 cp -p `mhpath last` "$expected"
584 run_prog mhfixmsg last
585 check
`mhpath last` "$expected" 'keep first'
588 # check for successful decode of a different part with attempted -decodetext
590 #### Generated the encoded text below with:
591 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
593 To: recipient@example.com
594 From: sender@example.com
595 Subject: mhfixmsg successful decode of text/plain with failed binary decode
597 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
599 ------- =_aaaaaaaaaa0
600 Content-Type: text/plain; charset="iso-8859-1"
601 Content-Transfer-Encoding: 8bit
603 This is a text plain part
605 ------- =_aaaaaaaaaa0
606 Content-Type: text/html; charset="ascii"
607 Content-Transfer-Encoding: base64
608 Content-Disposition: inline
610 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
611 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
612 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
613 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
614 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
615 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
616 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
617 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
618 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
619 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
620 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
621 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
622 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
623 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
624 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
625 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
626 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
627 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
628 ICA8L2JvZHk+PC9odG1sPg==
630 ------- =_aaaaaaaaaa0--
633 cat >`mhpath new` <<EOF
634 To: recipient@example.com
635 From: sender@example.com
636 Subject: mhfixmsg successful decode of text/plain with failed binary decode
638 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
640 ------- =_aaaaaaaaaa0
641 Content-Type: text/plain; charset="iso-8859-1"
642 Content-Transfer-Encoding: base64
644 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
646 ------- =_aaaaaaaaaa0
647 Content-Type: text/html; charset="ascii"
648 Content-Transfer-Encoding: base64
649 Content-Disposition: inline
651 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
652 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
653 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
654 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
655 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
656 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
657 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
658 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
659 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
660 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
661 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
662 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
663 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
664 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
665 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
666 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
667 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
668 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
669 ICA8L2JvZHk+PC9odG1sPg==
671 ------- =_aaaaaaaaaa0--
674 run_prog mhfixmsg
-noreformat last
675 check
`mhpath last` "$expected"
678 # check -decodetext of binary text
679 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
680 From: sender@example.com
681 Subject: mhfixmsg binary decode test
683 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
685 ------- =_aaaaaaaaaa0
686 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"nul+square.txt\"
687 Content-Transfer-Encoding: binary
691 ------- =_aaaaaaaaaa0--
693 ## output_content() in mhoutsbr.c can't handle binary content.
694 ## mhfixmsg last -decodetext binary -outfile "$actual"
695 ## check "$expected" "$actual"
700 # check that -reformat succeeds when decode of binary text fails
701 prepare_space
>"$expected" <<'EOF'
703 Date: Thu, 11 Apr 2013 02:47:08 -0700
705 From: <sender@example.com>
706 Subject: body requires binary encoding
707 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
709 ------=_nmh-multipart
710 Content-Type: text/plain; charset="ISO-8859-1"
711 Content-Transfer-Encoding: 8bit
716 Vehicle License Fee $1.84
719 ------=_nmh-multipart
720 Content-Type: text/html; charset="ISO-8859-1"
721 Content-Transfer-Encoding: quoted-printable
726 cat >`mhpath new` <<'EOF'
728 Content-Type: text/html; charset="ISO-8859-1"
729 Content-Transfer-Encoding: quoted-printable
730 Date: Thu, 11 Apr 2013 02:47:08 -0700
732 From: <sender@example.com>
733 Subject: body requires binary encoding
736 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
737 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
738 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
739 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
740 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
741 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
742 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
743 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
744 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
745 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
746 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
747 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
748 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
749 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
750 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
751 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
752 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
753 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
754 #333333" size=3D"2">$6.00</font></td></tr>
760 if [ $can_reformat_texthtml -eq 1 ]; then
761 #### lynx inserts multiple blank lines, so squeeze them.
762 #### Truncate to avoid comparing the html portion because it can
763 #### get reformatted.
764 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
765 check
"$expected" "$actual" 'ignore space'
767 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
773 # Also checks preservation of attributes after one (charset) that is
775 cat >"$expected" <<EOF
776 To: recipient@example.com
777 From: sender@example.com
778 Subject: mhfixmsg textcharset test
780 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
782 ------- =_aaaaaaaaaa0
783 Content-Type: text/plain; charset="utf-8"; name="square.txt"
784 Content-Disposition: attachment; filename="square.txt"
785 Content-Transfer-Encoding: 8bit
789 ------- =_aaaaaaaaaa0--
792 #### Generated the encoded text below with:
793 #### $ printf '\xbd\xb2=\xbc\n' | base64
794 cat >`mhpath new` <<EOF
795 To: recipient@example.com
796 From: sender@example.com
797 Subject: mhfixmsg textcharset test
799 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
801 ------- =_aaaaaaaaaa0
802 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
803 Content-Disposition: attachment; filename="square.txt"
804 Content-Transfer-Encoding: base64
808 ------- =_aaaaaaaaaa0--
811 if test "$ICONV_ENABLED" -eq 1; then
812 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
813 check
"$expected" "$actual"
815 echo "$0: skipping -textcharset check because nmh was built without iconv"
820 # check -nofixboundary
821 cat >"$expected" <<EOF
824 cat >`mhpath new` <<EOF
825 Date: Fri, 13 May 2011 08:21:12 -0500
826 Content-Type: multipart/alternative;
827 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
828 Content-Transfer-Encoding: 8bit
830 From: <sender@example.com>
831 To: <recipient@example.com>
832 Subject: mhfixmsg bad boundary test
834 This is a multi-part message in MIME format.
836 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
837 Content-Type: text/plain
839 The boundaries of this part don't match the header boundary.
841 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
844 cp -p `mhpath last` `mhpath new`
846 run_test
'mhfixmsg last -nofixboundary' ''
847 check
"$MH_TEST_DIR"/Mail
/inbox
/17 "$MH_TEST_DIR"/Mail
/inbox
/18 'keep first'
850 # check that message is not output when fed through stdin
851 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
852 check
"$expected" "$actual"
853 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
854 "$actual.err" >/dev
/null
; then
857 echo "$0: test failed, output is in $actual.err."
858 failed
=`expr ${failed:-0} + 1`
862 # check fixup of erroneous boundary in multipart (-fixboundary,
863 # enabled by default)
865 cat >"$expected" <<EOF
866 Date: Fri, 13 May 2011 08:21:12 -0500
867 Content-Type: multipart/alternative;
868 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
869 Content-Transfer-Encoding: 8bit
871 From: <sender@example.com>
872 To: <recipient@example.com>
873 Subject: mhfixmsg bad boundary test
875 This is a multi-part message in MIME format.
877 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
878 Content-Type: text/plain
880 The boundaries of this part don't match the header boundary.
882 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
885 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
886 "mhfixmsg: 17, fix multipart boundary"
887 check
"$expected" "$actual"
890 # check that message is not modified when -fixboundary fails
891 cat >`mhpath new` <<EOF
892 Date: Fri, 13 May 2011 08:21:12 -0500
893 Content-Type: multipart/alternative;
894 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
895 Content-Transfer-Encoding: 8bit
897 From: <sender@example.com>
898 To: <recipient@example.com>
899 Subject: mhfixmsg bad boundary test
901 This is a multi-part message in MIME format.
903 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
904 Content-Type: text/plain
906 The boundary below doesn't match the header boundary.
909 NextPart_000_1781A1A_01CC1147.81EBA8D4--
912 cp -p `mhpath last` "$expected"
913 run_test
"mhfixmsg last -outfile $actual" ''
914 check
"$expected" "$actual"
917 # check that text/plain part is not added to text/html in multipart/related
918 # when it shouldn't be
919 cat >`mhpath new` <<EOF
921 Date: Tue, 26 Feb 2013 18:07:20 -0600
922 Subject: multipart/related, not /alternative
923 Content-Type: multipart/related;
924 type="text/html"; boundary="----=_Part_90310_101292502.1"
926 ------=_Part_90310_101292502.1
927 Content-Type: text/html; charset="us-ascii"
928 Content-Transfer-Encoding: 7bit
931 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
932 <title>HTML Content</title>
935 This is the real content.
939 ------=_Part_90310_101292502.1
940 Content-Type: text/plain; charset="us-ascii"
941 Content-Transfer-Encoding: 7bit
943 Your email client does not support HTML messages
945 ------=_Part_90310_101292502.1--
948 cp -p `mhpath last` "$expected"
950 if [ $can_reformat_texthtml -eq 1 ]; then
951 #### lynx inserts multiple blank lines, so squeeze them.
952 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
953 check
"$expected" "$actual" 'ignore space'
959 # check that text/plain part is added to text/html in multipart/related
961 cat >"$expected" <<EOF
963 Date: Tue, 26 Feb 2013 18:07:20 -0600
964 Subject: multipart/related, not /alternative
965 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
967 ------=_Part_90310_101292502.1
968 Content-Type: text/plain; charset="us-ascii"
969 Content-Transfer-Encoding: 7bit
971 This is the real content.
973 ------=_Part_90310_101292502.1
974 Content-Type: text/html; charset="us-ascii"
975 Content-Transfer-Encoding: 7bit
978 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
979 <title>HTML Content</title>
982 This is the real content.
986 ------=_Part_90310_101292502.1--
989 cat >`mhpath new` <<EOF
991 Date: Tue, 26 Feb 2013 18:07:20 -0600
992 Subject: multipart/related, not /alternative
993 Content-Type: multipart/related;
994 type="text/html"; boundary="----=_Part_90310_101292502.1"
996 ------=_Part_90310_101292502.1
997 Content-Type: text/html; charset="us-ascii"
998 Content-Transfer-Encoding: 7bit
1001 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1002 <title>HTML Content</title>
1005 This is the real content.
1009 ------=_Part_90310_101292502.1--
1012 if [ $can_reformat_texthtml -eq 1 ]; then
1013 #### lynx inserts multiple blank lines, so squeeze them.
1014 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1015 check
"$expected" "$actual" 'ignore space'
1021 # check handling of rfc822 message type
1022 cat >"$expected" <<EOF
1023 From: Test <test@example.com>
1024 To: Some User <user@example.com>
1025 Date: Fri, 29 Sep 2006 00:00:00
1026 Message-Id: @test.nmh
1027 Subject: message with message/rfc822 attachment
1029 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1031 and some garbage before the attachment
1033 ------- =_aaaaaaaaaa0
1034 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1035 Content-Description: 1552
1036 Content-Disposition: attachment; filename="1552"
1038 From: Test <test@example.com>
1039 To: <another_user@example.com>
1040 Date: Thu, 28 Sep 2006 00:00:00
1041 Message-Id: @test.nmh
1042 Subject: message/rfc822 attachment
1044 This is an RFC-822 message.
1046 ------- =_aaaaaaaaaa0--
1048 and some garbage at the end
1051 cat >`mhpath new` <<EOF
1052 From: Test <test@example.com>
1053 To: Some User <user@example.com>
1054 Date: Fri, 29 Sep 2006 00:00:00
1055 Message-Id: @test.nmh
1056 Subject: message with message/rfc822 attachment
1058 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
1060 and some garbage before the attachment
1062 ------- =_aaaaaaaaaa0
1063 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1064 Content-Description: 1552
1065 Content-Disposition: attachment; filename="1552"
1067 From: Test <test@example.com>
1068 To: <another_user@example.com>
1069 Date: Thu, 28 Sep 2006 00:00:00
1070 Message-Id: @test.nmh
1071 Subject: message/rfc822 attachment
1073 This is an RFC-822 message.
1075 ------- =_aaaaaaaaaa0--
1077 and some garbage at the end
1080 run_test
'mhfixmsg last -outfile '"$actual" ''
1081 check
"$expected" "$actual"
1084 # check not stripping of CRs from ASCII text context (default)
1085 cat >"$expected" <<EOF
1087 From: sender@example.com
1088 To: recipient@example.com
1089 Subject: message with CR's
1090 Date: Mon, 29 Apr 2013 11:51:45 -0400
1092 There are two CR-LF pairs at the end of this sentence.
1096 cat >`mhpath new` <<'EOF'
1098 From: sender@example.com
1099 To: recipient@example.com
1100 Subject: message with CR's
1101 Date: Mon, 29 Apr 2013 11:51:45 -0400
1103 There are two CR-LF pairs at the end of this sentence.
1107 run_prog mhfixmsg last
-outfile "$actual"
1108 check
"$expected" "$actual"
1111 # check stripping of CRs from ASCII text context
1112 cat >"$expected" <<EOF
1114 From: sender@example.com
1115 To: recipient@example.com
1116 Subject: message with CR's
1117 Date: Mon, 29 Apr 2013 11:51:45 -0400
1119 There were two CR-LF pairs at the end of this sentence.
1123 cat >`mhpath new` <<'EOF'
1125 From: sender@example.com
1126 To: recipient@example.com
1127 Subject: message with CR's
1128 Date: Mon, 29 Apr 2013 11:51:45 -0400
1130 There were two CR-LF pairs at the end of this sentence.
1134 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1135 check
"$expected" "$actual"
1138 # check -replacetextplain
1139 prepare_space
>"$expected" <<EOF
1140 To: recipient@example.com
1141 From: sender@example.com
1142 Subject: mhfixmsg replacement of bad text/plain part test
1144 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1147 Content-Type: text/plain; charset="UTF-8"
1148 Content-Transfer-Encoding: 8bit
1150 Yes, the text/plain part really was empty.
1153 Content-Type: text/html; charset="UTF-8"
1154 Content-Transfer-Encoding: 8bit
1155 Content-Disposition: inline
1158 <title>eticket</title>
1161 Yes, the text/plain part really was empty.
1165 ------=_Part_876302--
1168 cat >`mhpath new` <<'EOF'
1169 To: recipient@example.com
1170 From: sender@example.com
1171 Subject: mhfixmsg replacement of bad text/plain part test
1173 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1176 Content-Type: text/plain; charset="iso-8859-15"
1177 Content-Transfer-Encoding: 7bit
1178 Content-Disposition: inline
1183 Content-Type: text/html; charset="UTF-8"
1184 Content-Transfer-Encoding: 8bit
1185 Content-Disposition: inline
1188 <title>eticket</title>
1191 Yes, the text/plain part really was empty.
1195 ------=_Part_876302--
1198 if [ $can_reformat_texthtml -eq 1 ]; then
1199 #### lynx inserts multiple blank lines, so squeeze them.
1200 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1201 squeeze_lines
> "$actual"
1202 check
"$expected" "$actual" 'ignore space'
1208 # check -noreplacetextplain
1209 cat >"$expected" <<EOF
1210 To: recipient@example.com
1211 From: sender@example.com
1212 Subject: mhfixmsg replacement of bad text/plain part test
1214 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1217 Content-Type: text/plain; charset="iso-8859-15"
1218 Content-Transfer-Encoding: 7bit
1219 Content-Disposition: inline
1224 Content-Type: text/html; charset="UTF-8"
1225 Content-Transfer-Encoding: 8bit
1226 Content-Disposition: inline
1229 <title>eticket</title>
1232 Yes, the text/plain part really was empty.
1236 ------=_Part_876302--
1239 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1240 check
"$expected" "$actual"
1243 # check removal of extraneous trailing semicolon from header parameter list
1244 cat >"$expected" <<EOF
1245 To: recipient@example.com
1247 From: sender@example.com
1249 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1251 ------- =_aaaaaaaaaa0
1252 Content-Type: text/plain; charset="us-ascii"
1256 ------- =_aaaaaaaaaa0
1257 Content-Type: text/plain; charset="us-ascii";
1259 Content-Description: check folded headers, with and without trailing semicolon
1260 Content-Disposition: attachment;
1265 ------- =_aaaaaaaaaa0--
1268 cat >`mhpath new` <<EOF
1269 To: recipient@example.com
1271 From: sender@example.com
1273 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1275 ------- =_aaaaaaaaaa0
1276 Content-Type: text/plain; charset="us-ascii";
1280 ------- =_aaaaaaaaaa0
1281 Content-Type: text/plain; charset="us-ascii";
1283 Content-Description: check folded headers, with and without trailing semicolon
1284 Content-Disposition: attachment;
1289 ------- =_aaaaaaaaaa0--
1291 run_test
'mhfixmsg last -outfile '"$actual" ''
1292 check
"$expected" "$actual"
1296 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1299 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1300 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1301 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1303 run_test
'mhfixmsg 15' ''
1304 check
"${MH_TEST_DIR}/Mail/inbox/15.backup" \
1305 "${MH_TEST_DIR}/Mail/inbox/15.original"
1309 cp "${MH_TEST_DIR}/Mail/inbox/20" "${MH_TEST_DIR}/Mail/inbox/21"
1311 run_test
'mhfixmsg 20 -normmproc'
1312 check
"${MH_TEST_DIR}/Mail/inbox/21" \
1313 "${MH_TEST_DIR}/Mail/inbox/,20" 'keep first'
1317 run_test
'mhfixmsg 21 -rmmproc true'
1318 if test -f '${MH_TEST_DIR}/Mail/inbox/21.backup'; then
1319 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1320 failed
=`expr ${failed:-0} + 1`
1325 cat >"$expected" <<EOF
1326 To: recipient@example.com
1327 From: sender@example.com
1328 Subject: mhfixmsg with incorrect Content-Type
1330 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1332 ------- =_aaaaaaaaaa0
1333 Content-Type: text/plain; name="plaintext.txt"
1337 ------- =_aaaaaaaaaa0--
1340 cat >`mhpath new` <<EOF
1341 To: recipient@example.com
1342 From: sender@example.com
1343 Subject: mhfixmsg with incorrect Content-Type
1345 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1347 ------- =_aaaaaaaaaa0
1348 Content-Type: application/octet-stream; name="plaintext.txt"
1352 ------- =_aaaaaaaaaa0--
1355 mhfixmsg
-fixtype application
/octet
-stream last
1356 check
"$expected" `mhpath last`
1359 # check default -decodetypes
1360 cat >$expected <<EOF
1361 To: recipient@example.com
1362 From: sender@example.com
1363 Subject: mhfixmsg decode test 3
1365 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1367 ------- =_aaaaaaaaaa0
1368 Content-Type: text/plain; charset="iso-8859-1"
1369 Content-Disposition: attachment; filename="test1.txt"
1370 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1371 Content-Transfer-Encoding: 8bit
1373 This is the text/plain part.
1375 ------- =_aaaaaaaaaa0
1376 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1377 Content-Disposition: attachment; filename="test2.txt"
1378 Content-Transfer-Encoding: 8bit
1382 This was the text/html part.
1387 ------- =_aaaaaaaaaa0--
1390 cat >`mhpath new` <<EOF
1391 To: recipient@example.com
1392 From: sender@example.com
1393 Subject: mhfixmsg decode test 3
1395 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1397 ------- =_aaaaaaaaaa0
1398 Content-Type: text/plain; charset="iso-8859-1"
1399 Content-Disposition: attachment; filename="test1.txt"
1400 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1401 Content-Transfer-Encoding: quoted-printable
1403 This is the text/plain part.
1405 ------- =_aaaaaaaaaa0
1406 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1407 Content-Disposition: attachment; filename="test2.txt"
1408 Content-Transfer-Encoding: base64
1410 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1411 Ym9keT4KPC9odG1sPgo=
1413 ------- =_aaaaaaaaaa0--
1415 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1416 check
"$expected" "$actual"
1419 # check -decodetypes text/plain
1420 cat >$expected <<EOF
1421 To: recipient@example.com
1422 From: sender@example.com
1423 Subject: mhfixmsg decode test 4
1425 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1427 ------- =_aaaaaaaaaa0
1428 Content-Type: text/plain; charset="iso-8859-1"
1429 Content-Disposition: attachment; filename="test1.txt"
1430 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1431 Content-Transfer-Encoding: 8bit
1433 This is the text/plain part.
1435 ------- =_aaaaaaaaaa0
1436 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1437 Content-Disposition: attachment; filename="test2.txt"
1438 Content-Transfer-Encoding: base64
1440 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1441 CjwvYm9keT4NCjwvaHRtbD4NCg==
1443 ------- =_aaaaaaaaaa0--
1446 cat >`mhpath new` <<EOF
1447 To: recipient@example.com
1448 From: sender@example.com
1449 Subject: mhfixmsg decode test 4
1451 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1453 ------- =_aaaaaaaaaa0
1454 Content-Type: text/plain; charset="iso-8859-1"
1455 Content-Disposition: attachment; filename="test1.txt"
1456 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1457 Content-Transfer-Encoding: quoted-printable
1459 This is the text/plain part.
1461 ------- =_aaaaaaaaaa0
1462 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1463 Content-Disposition: attachment; filename="test2.txt"
1464 Content-Transfer-Encoding: base64
1466 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1467 CjwvYm9keT4NCjwvaHRtbD4NCg==
1469 ------- =_aaaaaaaaaa0--
1471 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1472 check
"$expected" "$actual"
1475 # check -decodetypes attachment/ics
1476 cat >$expected <<EOF
1477 To: recipient@example.com
1478 From: sender@example.com
1479 Subject: mhfixmsg decode test 5
1481 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1483 ------- =_aaaaaaaaaa0
1484 Content-Type: text/plain; charset="iso-8859-1"
1485 Content-Disposition: attachment; filename="test1.txt"
1486 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1487 Content-Transfer-Encoding: 8bit
1489 This is the text/plain part.
1491 ------- =_aaaaaaaaaa0
1492 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1493 Content-Disposition: attachment; filename="invite.ics"
1494 Content-Transfer-Encoding: 8bit
1500 DTSTAMP:20150101T162400Z
1501 DTSTART:20150105T160000
1502 DTEND:20150105T163000
1503 SUMMARY:4 pm meeting
1507 ------- =_aaaaaaaaaa0--
1510 cat >`mhpath new` <<EOF
1511 To: recipient@example.com
1512 From: sender@example.com
1513 Subject: mhfixmsg decode test 5
1515 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1517 ------- =_aaaaaaaaaa0
1518 Content-Type: text/plain; charset="iso-8859-1"
1519 Content-Disposition: attachment; filename="test1.txt"
1520 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1521 Content-Transfer-Encoding: quoted-printable
1526 ------- =_aaaaaaaaaa0
1527 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1528 Content-Disposition: attachment; filename="invite.ics"
1529 Content-Transfer-Encoding: base64
1531 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1532 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1533 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1534 CkVORDpWQ0FMRU5EQVINCg==
1536 ------- =_aaaaaaaaaa0--
1538 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1539 check
"$expected" "$actual"
1542 # check -decodetypes attachment/ics and -nocrlflinebreaks
1543 cat >$expected <<EOF
1544 To: recipient@example.com
1545 From: sender@example.com
1546 Subject: mhfixmsg decode test 5
1548 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1550 ------- =_aaaaaaaaaa0
1551 Content-Type: text/plain; charset="iso-8859-1"
1552 Content-Disposition: attachment; filename="test1.txt"
1553 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1554 Content-Transfer-Encoding: 8bit
1556 This is the text/plain part.
1558 ------- =_aaaaaaaaaa0
1559 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1560 Content-Disposition: attachment; filename="invite.ics"
1561 Content-Transfer-Encoding: 8bit
1567 DTSTAMP:20150101T162400Z
1568 DTSTART:20150105T160000
1569 DTEND:20150105T163000
1570 SUMMARY:4 pm meeting
1574 ------- =_aaaaaaaaaa0--
1577 cat >`mhpath new` <<EOF
1578 To: recipient@example.com
1579 From: sender@example.com
1580 Subject: mhfixmsg decode test 5
1582 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1584 ------- =_aaaaaaaaaa0
1585 Content-Type: text/plain; charset="iso-8859-1"
1586 Content-Disposition: attachment; filename="test1.txt"
1587 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1588 Content-Transfer-Encoding: quoted-printable
1593 ------- =_aaaaaaaaaa0
1594 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1595 Content-Disposition: attachment; filename="invite.ics"
1596 Content-Transfer-Encoding: base64
1598 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1599 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1600 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1601 CkVORDpWQ0FMRU5EQVINCg==
1603 ------- =_aaaaaaaaaa0--
1605 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1606 check
"$expected" "$actual"
1609 # check that input is passed through to output when there's a parse error
1610 # (the charset string is missing its closing quote) with -outfile
1611 cat >"$expected.err" <<EOF
1612 mhfixmsg: invalid quoted-string in message 30's Content-Type: field
1614 mhfixmsg: unable to parse message 30
1617 cat >`mhpath new` <<EOF
1618 To: recipient@example.com
1619 From: sender@example.com
1620 Subject: mhfixmsg pass through on parse error
1622 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1624 ------- =_aaaaaaaaaa0
1625 Content-Type: text/plain; charset="iso-8859-1
1626 Content-Disposition: attachment; filename="test1.txt"
1627 Content-Transfer-Encoding: quoted-printable
1632 ------- =_aaaaaaaaaa0--
1635 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1637 #### Expected output is identical to the input message.
1638 check
`mhpath last` "$actual" 'keep first'
1639 check
"$expected.err" "$actual.err"
1642 # check that input is passed through to output when there's a parse error
1643 # (the charset string is missing its closing quote) with -outfile, and
1644 # input from stdin. Don't check err output, because it contains the name
1645 # of a tmp file. It's similar to that of the previous check.
1647 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1649 #### Expected output is identical to the input message.
1650 check
`mhpath last` "$actual"
1653 # make sure there are no tmp files left over
1654 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1656 cat >"$expected" <<EOF
1659 check
"$expected" "$actual"