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]
52 -decodetext 8bit|7bit|binary
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 (default, 8 bit) -decodetext of binary text
565 #### Generated the encoded text below with:
566 #### $ printf '\xbd\xb2=\xbc\x00\n' | base64
567 cat >`mhpath new` <<EOF
568 To: recipient@example.com
569 From: sender@example.com
570 Subject: mhfixmsg binary decode test
572 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
574 ------- =_aaaaaaaaaa0
575 Content-Type: text/plain; charset=UTF-8; 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
589 # of binary (>998 characters) text
591 To: recipient@example.com
592 From: sender@example.com
593 Subject: mhfixmsg successful decode of text/plain with failed binary decode
595 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
597 ------- =_aaaaaaaaaa0
598 Content-Type: text/plain; charset="iso-8859-1"
599 Content-Transfer-Encoding: 8bit
601 This is a text plain part
603 ------- =_aaaaaaaaaa0
604 Content-Type: text/html; charset="ascii"
605 Content-Transfer-Encoding: base64
606 Content-Disposition: inline
608 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
609 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
610 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
611 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
612 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
613 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
614 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
615 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
616 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
617 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
618 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
619 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
620 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
621 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
622 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
623 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
624 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
625 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
626 ICA8L2JvZHk+PC9odG1sPg==
628 ------- =_aaaaaaaaaa0--
631 cat >`mhpath new` <<EOF
632 To: recipient@example.com
633 From: sender@example.com
634 Subject: mhfixmsg successful decode of text/plain with failed binary decode
636 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
638 ------- =_aaaaaaaaaa0
639 Content-Type: text/plain; charset="iso-8859-1"
640 Content-Transfer-Encoding: base64
642 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
644 ------- =_aaaaaaaaaa0
645 Content-Type: text/html; charset="ascii"
646 Content-Transfer-Encoding: base64
647 Content-Disposition: inline
649 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
650 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
651 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
652 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
653 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
654 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
655 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
656 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
657 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
658 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
659 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
660 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
661 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
662 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
663 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
664 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
665 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
666 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
667 ICA8L2JvZHk+PC9odG1sPg==
669 ------- =_aaaaaaaaaa0--
672 run_prog mhfixmsg
-noreformat last
673 check
`mhpath last` "$expected" 'keep first'
676 # check for successful decode of a different part with -decodetext of binary
677 # (>998 characters) text
679 To: recipient@example.com
680 From: sender@example.com
681 Subject: mhfixmsg successful decode of text/plain with failed binary decode
683 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
685 ------- =_aaaaaaaaaa0
686 Content-Type: text/plain; charset="iso-8859-1"
687 Content-Transfer-Encoding: 8bit
689 This is a text plain part
691 ------- =_aaaaaaaaaa0
692 Content-Type: text/html; charset="ascii"
693 Content-Transfer-Encoding: binary
694 Content-Disposition: inline
696 <html><head><title>long line</title></head><body>This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. </body></html>
698 ------- =_aaaaaaaaaa0--
701 run_prog mhfixmsg
-noreformat -decodetext binary last
702 check
`mhpath last` "$expected"
705 # check -decodetext of binary (containing ASCII NUL) text
706 printf "%s\xbd\xb2=\xbc\x00%s" "To: recipient@example.com
707 From: sender@example.com
708 Subject: mhfixmsg binary decode test
710 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
712 ------- =_aaaaaaaaaa0
713 Content-Type: text/plain; charset=UTF-8; name=\"nul+square.txt\"
714 Content-Transfer-Encoding: binary
718 ------- =_aaaaaaaaaa0--
720 mhfixmsg last
-decodetext binary
-outfile "$actual"
721 check
"$expected" "$actual"
724 # check that -reformat succeeds when decode of binary text fails
725 prepare_space
>"$expected" <<'EOF'
727 Date: Thu, 11 Apr 2013 02:47:08 -0700
729 From: <sender@example.com>
730 Subject: body requires binary encoding
731 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
733 ------=_nmh-multipart
734 Content-Type: text/plain; charset="ISO-8859-1"
735 Content-Transfer-Encoding: 8bit
740 Vehicle License Fee $1.84
743 ------=_nmh-multipart
744 Content-Type: text/html; charset="ISO-8859-1"
745 Content-Transfer-Encoding: quoted-printable
750 cat >`mhpath new` <<'EOF'
752 Content-Type: text/html; charset="ISO-8859-1"
753 Content-Transfer-Encoding: quoted-printable
754 Date: Thu, 11 Apr 2013 02:47:08 -0700
756 From: <sender@example.com>
757 Subject: body requires binary encoding
760 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
761 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
762 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
763 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
764 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
765 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
766 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
767 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
768 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
769 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
770 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
771 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
772 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
773 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
774 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
775 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
776 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
777 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
778 #333333" size=3D"2">$6.00</font></td></tr>
784 if [ $can_reformat_texthtml -eq 1 ]; then
785 #### lynx inserts multiple blank lines, so squeeze them.
786 #### Truncate to avoid comparing the html portion because it can
787 #### get reformatted.
788 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
789 check
"$expected" "$actual" 'ignore space'
791 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
797 # Also checks preservation of attributes after one (charset) that is
799 cat >"$expected" <<EOF
800 To: recipient@example.com
801 From: sender@example.com
802 Subject: mhfixmsg textcharset test
804 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
806 ------- =_aaaaaaaaaa0
807 Content-Type: text/plain; charset="utf-8"; name="square.txt"
808 Content-Disposition: attachment; filename="square.txt"
809 Content-Transfer-Encoding: 8bit
813 ------- =_aaaaaaaaaa0--
816 #### Generated the encoded text below with:
817 #### $ printf '\xbd\xb2=\xbc\n' | base64
818 cat >`mhpath new` <<EOF
819 To: recipient@example.com
820 From: sender@example.com
821 Subject: mhfixmsg textcharset test
823 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
825 ------- =_aaaaaaaaaa0
826 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
827 Content-Disposition: attachment; filename="square.txt"
828 Content-Transfer-Encoding: base64
832 ------- =_aaaaaaaaaa0--
835 if test "$ICONV_ENABLED" -eq 1; then
836 run_prog mhfixmsg last
-textcharset utf-8
-outfile "$actual" 2>&1
837 check
"$expected" "$actual"
839 echo "$0: skipping -textcharset check because nmh was built without iconv"
844 # check -nofixboundary
845 cat >"$expected" <<EOF
848 cat >`mhpath new` <<EOF
849 Date: Fri, 13 May 2011 08:21:12 -0500
850 Content-Type: multipart/alternative;
851 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
852 Content-Transfer-Encoding: 8bit
854 From: <sender@example.com>
855 To: <recipient@example.com>
856 Subject: mhfixmsg bad boundary test
858 This is a multi-part message in MIME format.
860 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
861 Content-Type: text/plain
863 The boundaries of this part don't match the header boundary.
865 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
868 cp -p `mhpath last` `mhpath new`
870 run_test
'mhfixmsg last -nofixboundary' ''
871 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
874 # check that message is not output when fed through stdin
875 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
876 check
"$expected" "$actual"
877 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
878 "$actual.err" >/dev
/null
; then
881 echo "$0: test failed, output is in $actual.err."
882 failed
=`expr ${failed:-0} + 1`
886 # check fixup of erroneous boundary in multipart (-fixboundary,
887 # enabled by default)
889 cat >"$expected" <<EOF
890 Date: Fri, 13 May 2011 08:21:12 -0500
891 Content-Type: multipart/alternative;
892 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
893 Content-Transfer-Encoding: 8bit
895 From: <sender@example.com>
896 To: <recipient@example.com>
897 Subject: mhfixmsg bad boundary test
899 This is a multi-part message in MIME format.
901 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
902 Content-Type: text/plain
904 The boundaries of this part don't match the header boundary.
906 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
909 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
910 "mhfixmsg: 18, fix multipart boundary"
911 check
"$expected" "$actual"
914 # check that message is not modified when -fixboundary fails
915 cat >`mhpath new` <<EOF
916 Date: Fri, 13 May 2011 08:21:12 -0500
917 Content-Type: multipart/alternative;
918 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
919 Content-Transfer-Encoding: 8bit
921 From: <sender@example.com>
922 To: <recipient@example.com>
923 Subject: mhfixmsg bad boundary test
925 This is a multi-part message in MIME format.
927 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
928 Content-Type: text/plain
930 The boundary below doesn't match the header boundary.
933 NextPart_000_1781A1A_01CC1147.81EBA8D4--
936 cp -p `mhpath last` "$expected"
937 run_test
"mhfixmsg last -outfile $actual" ''
938 check
"$expected" "$actual"
941 # check that text/plain part is not added to text/html in multipart/related
942 # when it shouldn't be
943 cat >`mhpath new` <<EOF
945 Date: Tue, 26 Feb 2013 18:07:20 -0600
946 Subject: multipart/related, not /alternative
947 Content-Type: multipart/related;
948 type="text/html"; boundary="----=_Part_90310_101292502.1"
950 ------=_Part_90310_101292502.1
951 Content-Type: text/html; charset="us-ascii"
952 Content-Transfer-Encoding: 7bit
955 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
956 <title>HTML Content</title>
959 This is the real content.
963 ------=_Part_90310_101292502.1
964 Content-Type: text/plain; charset="us-ascii"
965 Content-Transfer-Encoding: 7bit
967 Your email client does not support HTML messages
969 ------=_Part_90310_101292502.1--
972 cp -p `mhpath last` "$expected"
974 if [ $can_reformat_texthtml -eq 1 ]; then
975 #### lynx inserts multiple blank lines, so squeeze them.
976 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
977 check
"$expected" "$actual" 'ignore space'
983 # check that text/plain part is added to text/html in multipart/related
985 cat >"$expected" <<EOF
987 Date: Tue, 26 Feb 2013 18:07:20 -0600
988 Subject: multipart/related, not /alternative
989 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
991 ------=_Part_90310_101292502.1
992 Content-Type: text/plain; charset="us-ascii"
993 Content-Transfer-Encoding: 7bit
995 This is the real content.
997 ------=_Part_90310_101292502.1
998 Content-Type: text/html; charset="us-ascii"
999 Content-Transfer-Encoding: 7bit
1002 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1003 <title>HTML Content</title>
1006 This is the real content.
1010 ------=_Part_90310_101292502.1--
1013 cat >`mhpath new` <<EOF
1015 Date: Tue, 26 Feb 2013 18:07:20 -0600
1016 Subject: multipart/related, not /alternative
1017 Content-Type: multipart/related;
1018 type="text/html"; boundary="----=_Part_90310_101292502.1"
1020 ------=_Part_90310_101292502.1
1021 Content-Type: text/html; charset="us-ascii"
1022 Content-Transfer-Encoding: 7bit
1025 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1026 <title>HTML Content</title>
1029 This is the real content.
1033 ------=_Part_90310_101292502.1--
1036 if [ $can_reformat_texthtml -eq 1 ]; then
1037 #### lynx inserts multiple blank lines, so squeeze them.
1038 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1039 check
"$expected" "$actual" 'ignore space'
1045 # check handling of rfc822 message type
1046 cat >"$expected" <<EOF
1047 From: Test <test@example.com>
1048 To: Some User <user@example.com>
1049 Date: Fri, 29 Sep 2006 00:00:00
1050 Message-Id: @test.nmh
1051 Subject: message with message/rfc822 attachment
1053 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1055 and some garbage before the attachment
1057 ------- =_aaaaaaaaaa0
1058 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1059 Content-Description: 1552
1060 Content-Disposition: attachment; filename="1552"
1062 From: Test <test@example.com>
1063 To: <another_user@example.com>
1064 Date: Thu, 28 Sep 2006 00:00:00
1065 Message-Id: @test.nmh
1066 Subject: message/rfc822 attachment
1068 This is an RFC-822 message.
1070 ------- =_aaaaaaaaaa0--
1072 and some garbage at the end
1075 cat >`mhpath new` <<EOF
1076 From: Test <test@example.com>
1077 To: Some User <user@example.com>
1078 Date: Fri, 29 Sep 2006 00:00:00
1079 Message-Id: @test.nmh
1080 Subject: message with message/rfc822 attachment
1082 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
1084 and some garbage before the attachment
1086 ------- =_aaaaaaaaaa0
1087 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1088 Content-Description: 1552
1089 Content-Disposition: attachment; filename="1552"
1091 From: Test <test@example.com>
1092 To: <another_user@example.com>
1093 Date: Thu, 28 Sep 2006 00:00:00
1094 Message-Id: @test.nmh
1095 Subject: message/rfc822 attachment
1097 This is an RFC-822 message.
1099 ------- =_aaaaaaaaaa0--
1101 and some garbage at the end
1104 run_test
'mhfixmsg last -outfile '"$actual" ''
1105 check
"$expected" "$actual"
1108 # check not stripping of CRs from ASCII text context (default)
1109 cat >"$expected" <<EOF
1111 From: sender@example.com
1112 To: recipient@example.com
1113 Subject: message with CR's
1114 Date: Mon, 29 Apr 2013 11:51:45 -0400
1116 There are two CR-LF pairs at the end of this sentence.
1120 cat >`mhpath new` <<'EOF'
1122 From: sender@example.com
1123 To: recipient@example.com
1124 Subject: message with CR's
1125 Date: Mon, 29 Apr 2013 11:51:45 -0400
1127 There are two CR-LF pairs at the end of this sentence.
1131 run_prog mhfixmsg last
-outfile "$actual"
1132 check
"$expected" "$actual"
1135 # check stripping of CRs from ASCII text context
1136 cat >"$expected" <<EOF
1138 From: sender@example.com
1139 To: recipient@example.com
1140 Subject: message with CR's
1141 Date: Mon, 29 Apr 2013 11:51:45 -0400
1143 There were two CR-LF pairs at the end of this sentence.
1147 cat >`mhpath new` <<'EOF'
1149 From: sender@example.com
1150 To: recipient@example.com
1151 Subject: message with CR's
1152 Date: Mon, 29 Apr 2013 11:51:45 -0400
1154 There were two CR-LF pairs at the end of this sentence.
1158 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1159 check
"$expected" "$actual"
1162 # check -replacetextplain
1163 prepare_space
>"$expected" <<EOF
1164 To: recipient@example.com
1165 From: sender@example.com
1166 Subject: mhfixmsg replacement of bad text/plain part test
1168 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1171 Content-Type: text/plain; charset="UTF-8"
1172 Content-Transfer-Encoding: 8bit
1174 Yes, the text/plain part really was empty.
1177 Content-Type: text/html; charset="UTF-8"
1178 Content-Transfer-Encoding: 8bit
1179 Content-Disposition: inline
1182 <title>eticket</title>
1185 Yes, the text/plain part really was empty.
1189 ------=_Part_876302--
1192 cat >`mhpath new` <<'EOF'
1193 To: recipient@example.com
1194 From: sender@example.com
1195 Subject: mhfixmsg replacement of bad text/plain part test
1197 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1200 Content-Type: text/plain; charset="iso-8859-15"
1201 Content-Transfer-Encoding: 7bit
1202 Content-Disposition: inline
1207 Content-Type: text/html; charset="UTF-8"
1208 Content-Transfer-Encoding: 8bit
1209 Content-Disposition: inline
1212 <title>eticket</title>
1215 Yes, the text/plain part really was empty.
1219 ------=_Part_876302--
1222 if [ $can_reformat_texthtml -eq 1 ]; then
1223 #### lynx inserts multiple blank lines, so squeeze them.
1224 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1225 squeeze_lines
> "$actual"
1226 check
"$expected" "$actual" 'ignore space'
1232 # check -noreplacetextplain
1233 cat >"$expected" <<EOF
1234 To: recipient@example.com
1235 From: sender@example.com
1236 Subject: mhfixmsg replacement of bad text/plain part test
1238 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1241 Content-Type: text/plain; charset="iso-8859-15"
1242 Content-Transfer-Encoding: 7bit
1243 Content-Disposition: inline
1248 Content-Type: text/html; charset="UTF-8"
1249 Content-Transfer-Encoding: 8bit
1250 Content-Disposition: inline
1253 <title>eticket</title>
1256 Yes, the text/plain part really was empty.
1260 ------=_Part_876302--
1263 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1264 check
"$expected" "$actual"
1267 # check removal of extraneous trailing semicolon from header parameter list
1268 cat >"$expected" <<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--
1292 cat >`mhpath new` <<EOF
1293 To: recipient@example.com
1295 From: sender@example.com
1297 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1299 ------- =_aaaaaaaaaa0
1300 Content-Type: text/plain; charset="us-ascii";
1304 ------- =_aaaaaaaaaa0
1305 Content-Type: text/plain; charset="us-ascii";
1307 Content-Description: check folded headers, with and without trailing semicolon
1308 Content-Disposition: attachment;
1313 ------- =_aaaaaaaaaa0--
1315 run_test
'mhfixmsg last -outfile '"$actual" ''
1316 check
"$expected" "$actual"
1320 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1323 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1324 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1325 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1327 run_test
'mhfixmsg 16' ''
1328 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1329 "${MH_TEST_DIR}/Mail/inbox/16.original"
1333 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1335 run_test
'mhfixmsg 21 -normmproc'
1336 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1337 "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
1341 run_test
'mhfixmsg 21 -rmmproc true'
1342 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1343 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1344 failed
=`expr ${failed:-0} + 1`
1349 cat >"$expected" <<EOF
1350 To: recipient@example.com
1351 From: sender@example.com
1352 Subject: mhfixmsg with incorrect Content-Type
1354 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1356 ------- =_aaaaaaaaaa0
1357 Content-Type: text/plain; name="plaintext.txt"
1361 ------- =_aaaaaaaaaa0--
1364 cat >`mhpath new` <<EOF
1365 To: recipient@example.com
1366 From: sender@example.com
1367 Subject: mhfixmsg with incorrect Content-Type
1369 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1371 ------- =_aaaaaaaaaa0
1372 Content-Type: application/octet-stream; name="plaintext.txt"
1376 ------- =_aaaaaaaaaa0--
1379 mhfixmsg
-fixtype application
/octet-stream last
1380 check
"$expected" `mhpath last`
1383 # check default -decodetypes
1384 cat >$expected <<EOF
1385 To: recipient@example.com
1386 From: sender@example.com
1387 Subject: mhfixmsg decode test 3
1389 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1391 ------- =_aaaaaaaaaa0
1392 Content-Type: text/plain; charset="iso-8859-1"
1393 Content-Disposition: attachment; filename="test1.txt"
1394 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1395 Content-Transfer-Encoding: 8bit
1397 This is the text/plain part.
1399 ------- =_aaaaaaaaaa0
1400 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1401 Content-Disposition: attachment; filename="test2.txt"
1402 Content-Transfer-Encoding: 8bit
1406 This was the text/html part.
1411 ------- =_aaaaaaaaaa0--
1414 cat >`mhpath new` <<EOF
1415 To: recipient@example.com
1416 From: sender@example.com
1417 Subject: mhfixmsg decode test 3
1419 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1421 ------- =_aaaaaaaaaa0
1422 Content-Type: text/plain; charset="iso-8859-1"
1423 Content-Disposition: attachment; filename="test1.txt"
1424 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1425 Content-Transfer-Encoding: quoted-printable
1427 This is the text/plain part.
1429 ------- =_aaaaaaaaaa0
1430 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1431 Content-Disposition: attachment; filename="test2.txt"
1432 Content-Transfer-Encoding: base64
1434 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1435 Ym9keT4KPC9odG1sPgo=
1437 ------- =_aaaaaaaaaa0--
1439 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1440 check
"$expected" "$actual"
1443 # check -decodetypes text/plain
1444 cat >$expected <<EOF
1445 To: recipient@example.com
1446 From: sender@example.com
1447 Subject: mhfixmsg decode test 4
1449 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1451 ------- =_aaaaaaaaaa0
1452 Content-Type: text/plain; charset="iso-8859-1"
1453 Content-Disposition: attachment; filename="test1.txt"
1454 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1455 Content-Transfer-Encoding: 8bit
1457 This is the text/plain part.
1459 ------- =_aaaaaaaaaa0
1460 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1461 Content-Disposition: attachment; filename="test2.txt"
1462 Content-Transfer-Encoding: base64
1464 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1465 CjwvYm9keT4NCjwvaHRtbD4NCg==
1467 ------- =_aaaaaaaaaa0--
1470 cat >`mhpath new` <<EOF
1471 To: recipient@example.com
1472 From: sender@example.com
1473 Subject: mhfixmsg decode test 4
1475 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1477 ------- =_aaaaaaaaaa0
1478 Content-Type: text/plain; charset="iso-8859-1"
1479 Content-Disposition: attachment; filename="test1.txt"
1480 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1481 Content-Transfer-Encoding: quoted-printable
1483 This is the text/plain part.
1485 ------- =_aaaaaaaaaa0
1486 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1487 Content-Disposition: attachment; filename="test2.txt"
1488 Content-Transfer-Encoding: base64
1490 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1491 CjwvYm9keT4NCjwvaHRtbD4NCg==
1493 ------- =_aaaaaaaaaa0--
1495 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1496 check
"$expected" "$actual"
1499 # check -decodetypes attachment/ics
1500 cat >$expected <<EOF
1501 To: recipient@example.com
1502 From: sender@example.com
1503 Subject: mhfixmsg decode test 5
1505 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1507 ------- =_aaaaaaaaaa0
1508 Content-Type: text/plain; charset="iso-8859-1"
1509 Content-Disposition: attachment; filename="test1.txt"
1510 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1511 Content-Transfer-Encoding: 8bit
1513 This is the text/plain part.
1515 ------- =_aaaaaaaaaa0
1516 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1517 Content-Disposition: attachment; filename="invite.ics"
1518 Content-Transfer-Encoding: 8bit
1524 DTSTAMP:20150101T162400Z
1525 DTSTART:20150105T160000
1526 DTEND:20150105T163000
1527 SUMMARY:4 pm meeting
1531 ------- =_aaaaaaaaaa0--
1534 cat >`mhpath new` <<EOF
1535 To: recipient@example.com
1536 From: sender@example.com
1537 Subject: mhfixmsg decode test 5
1539 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1541 ------- =_aaaaaaaaaa0
1542 Content-Type: text/plain; charset="iso-8859-1"
1543 Content-Disposition: attachment; filename="test1.txt"
1544 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1545 Content-Transfer-Encoding: quoted-printable
1550 ------- =_aaaaaaaaaa0
1551 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1552 Content-Disposition: attachment; filename="invite.ics"
1553 Content-Transfer-Encoding: base64
1555 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1556 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1557 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1558 CkVORDpWQ0FMRU5EQVINCg==
1560 ------- =_aaaaaaaaaa0--
1562 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1563 check
"$expected" "$actual"
1566 # check -decodetypes attachment/ics and -nocrlflinebreaks
1567 cat >$expected <<EOF
1568 To: recipient@example.com
1569 From: sender@example.com
1570 Subject: mhfixmsg decode test 5
1572 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1574 ------- =_aaaaaaaaaa0
1575 Content-Type: text/plain; charset="iso-8859-1"
1576 Content-Disposition: attachment; filename="test1.txt"
1577 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1578 Content-Transfer-Encoding: 8bit
1580 This is the text/plain part.
1582 ------- =_aaaaaaaaaa0
1583 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1584 Content-Disposition: attachment; filename="invite.ics"
1585 Content-Transfer-Encoding: 8bit
1591 DTSTAMP:20150101T162400Z
1592 DTSTART:20150105T160000
1593 DTEND:20150105T163000
1594 SUMMARY:4 pm meeting
1598 ------- =_aaaaaaaaaa0--
1601 cat >`mhpath new` <<EOF
1602 To: recipient@example.com
1603 From: sender@example.com
1604 Subject: mhfixmsg decode test 5
1606 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1608 ------- =_aaaaaaaaaa0
1609 Content-Type: text/plain; charset="iso-8859-1"
1610 Content-Disposition: attachment; filename="test1.txt"
1611 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1612 Content-Transfer-Encoding: quoted-printable
1617 ------- =_aaaaaaaaaa0
1618 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1619 Content-Disposition: attachment; filename="invite.ics"
1620 Content-Transfer-Encoding: base64
1622 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1623 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1624 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1625 CkVORDpWQ0FMRU5EQVINCg==
1627 ------- =_aaaaaaaaaa0--
1629 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1630 check
"$expected" "$actual"
1633 # check that input is passed through to output when there's a parse error
1634 # (the charset string is missing its closing quote) with -outfile
1635 cat >"$expected.err" <<EOF
1636 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1638 mhfixmsg: unable to parse message 31
1641 cat >`mhpath new` <<EOF
1642 To: recipient@example.com
1643 From: sender@example.com
1644 Subject: mhfixmsg pass through on parse error
1646 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1648 ------- =_aaaaaaaaaa0
1649 Content-Type: text/plain; charset="iso-8859-1
1650 Content-Disposition: attachment; filename="test1.txt"
1651 Content-Transfer-Encoding: quoted-printable
1656 ------- =_aaaaaaaaaa0--
1659 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1661 #### Expected output is identical to the input message.
1662 check
`mhpath last` "$actual" 'keep first'
1663 check
"$expected.err" "$actual.err"
1666 # check that input is passed through to output when there's a parse error
1667 # (the charset string is missing its closing quote) with -outfile, and
1668 # input from stdin. Don't check err output, because it contains the name
1669 # of a tmp file. It's similar to that of the previous check.
1671 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1673 #### Expected output is identical to the input message.
1674 check
`mhpath last` "$actual"
1677 # make sure there are no tmp files left over
1678 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1680 cat >"$expected" <<EOF
1683 check
"$expected" "$actual"