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 check_exit
'-eq 1' mhfixmsg
-
21 #### Make sure that html-to-text conversion is what we expect.
22 require_locale en_US.UTF
-8 en_US.UTF8 en_US.utf
-8 en_US.utf8
24 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
25 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
26 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
27 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
29 mhn_defaults
="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
31 if grep mhfixmsg
-format-text/html
"${mhn_defaults}" >/dev
/null
; then
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
50 cat >"$expected" <<EOF
51 Usage: mhfixmsg [+folder] [msgs] [switches]
53 -decodetext 8bit|7bit|binary
56 -decodeheaderfieldbodies utf-8
57 -nodecodeheaderfieldbodies
76 #### Skip nmh intro text.
77 run_prog mhfixmsg
-help 2>&1 | sed '/^$/,$d' >"$actual"
78 check
"$expected" "$actual"
83 case `mhfixmsg -version` in
85 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
86 failed
=`expr ${failed:-0} + 1`;;
90 # check that non-MIME messages aren't modified
92 start_test
"non-MIME messages aren't modified, and -outfile"
93 run_test
'mhfixmsg first -outfile '"$actual" ''
94 check
"`mhpath first`" "$actual" 'keep first'
97 # check that non-MIME messages with no bodies aren't modified
99 start_test
"non-MIME messages with no bodies aren't modified, and -outfile"
100 cat >"`mhpath new`" <<EOF
101 From: Test <test@example.com>
102 To: Some User <user@example.com>
103 Date: Fri, 29 Sep 2006 00:00:00
104 Message-Id: @test.nmh
105 Subject: message with no body
108 run_test
'mhfixmsg last -outfile '"$actual" ''
109 check
"`mhpath last`" "$actual"
113 start_test
"-nofixcte"
114 cat >"`mhpath new`" <<EOF
117 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
118 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
120 Content-Type: MULTIPART/MIXED;
121 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
122 Content-Transfer-Encoding: QUOTED-PRINTABLE
124 This message is in MIME format. The first part should be readable
126 while the remaining parts are likely unreadable without MIME-aware
129 ------=_NextPart_000_0000_00000000.00000000
130 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
131 Content-Transfer-Encoding: 8BIT
133 Some text in swedish.
135 Varf=C3=B6r inte anv=C3=A4nda...
137 ------=_NextPart_000_0000_00000000.00000000--
139 And some text after the last part.
142 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
144 run_test
'mhfixmsg last -nofixcte' ''
145 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
148 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
150 start_test
"-fixcte (enabled by default): fixup of erroneous C-T-E in multipart, and -verbose"
151 cat >"$expected" <<EOF
154 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
155 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
157 Content-Type: MULTIPART/MIXED;
158 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
159 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
160 Content-Transfer-Encoding: 8bit
162 This message is in MIME format. The first part should be readable
164 while the remaining parts are likely unreadable without MIME-aware
167 ------=_NextPart_000_0000_00000000.00000000
168 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
169 Content-Transfer-Encoding: 8BIT
171 Some text in swedish.
173 Varf=C3=B6r inte anv=C3=A4nda...
175 ------=_NextPart_000_0000_00000000.00000000--
177 And some text after the last part.
180 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
181 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
182 QUOTED-PRINTABLE with 8 bit"
183 check
"$expected" "$actual" 'keep first'
185 sbackup
="`mhparam sbackup`"
187 # check with no options: checks backup
188 start_test
"with no options: checks backup"
189 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
190 folder last
>/dev
/null
191 run_test
'mhfixmsg' ''
192 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
193 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
194 check
"$MH_TEST_DIR/Mail/inbox/${sbackup}11" "$MH_TEST_DIR"/Mail
/inbox
/11.original
197 # check backup with -file
198 start_test
"backup with -file"
199 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
200 folder last
>/dev
/null
201 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
202 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
203 check
"$MH_TEST_DIR/Mail/inbox/${sbackup}11" "$MH_TEST_DIR"/Mail
/inbox
/11.original
206 # check -file with directory
207 start_test
"-file with directory"
208 run_test
'mhfixmsg -file /tmp' 'mhfixmsg: /tmp is a directory
209 mhfixmsg: unable to parse message from file /tmp'
212 # check -reformat (enabled by default): addition of text/plain part
213 # to solitary text/html part
214 start_test
"-reformat (enabled by default): addition of text/plain part"
215 prepare_space
>"$expected" <<EOF
217 From: sender@example.com
218 To: bonquiqui@example.com
220 Date: Sat, 26 Jan 2013 17:37:53 -0500
221 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
223 ------=_nmh-multipart
224 Content-Type: text/plain; charset="Windows-1252"
225 Content-Transfer-Encoding: 7bit
227 Need to go! Need ... to ... go!
229 ------=_nmh-multipart
230 Content-Type: text/html; charset="Windows-1252"
231 Content-Transfer-Encoding: 7bit
235 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
236 <meta name="Generator" content="Microsoft Exchange Server">
237 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
241 <div>Need to go! Need ... to ... go!</div>
245 ------=_nmh-multipart--
248 cat >"`mhpath new`" <<EOF
250 From: sender@example.com
251 To: bonquiqui@example.com
253 Date: Sat, 26 Jan 2013 17:37:53 -0500
254 Content-Type: text/html; charset="Windows-1252"
255 Content-Transfer-Encoding: quoted-printable
259 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
261 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
262 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
263 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
267 <div>Need to go! Need ... to ... go!</div>
272 if [ $can_reformat_texthtml -eq 1 ]; then
273 printf '%s\n' "mhfixmsg: 12, insert text/plain part
274 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
277 #### lynx inserts multiple blank lines, so squeeze them.
278 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
279 squeeze_lines
>"$actual"
280 check
"$expected" "$actual" 'ignore space'
281 check
"$expected.err" "$actual.err"
287 # check implicit -file with absolute pathname
288 start_test
"implicit -file with absolute pathname"
289 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
292 # check handling of boundary string that appears in message body
293 start_test
"handling of boundary string that appears in message body"
294 prepare_space
>"$expected" <<EOF
296 From: sender@example.com
297 To: bonquiqui@example.com
299 Date: Sat, 26 Jan 2013 17:37:53 -0500
300 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
302 ------=_nmh-multipart-3
303 Content-Type: text/plain; charset="Windows-1252"
304 Content-Transfer-Encoding: 7bit
306 ------=_nmh-multipart
307 ------=_nmh-multipart-1
308 ------=_nmh-multipart-2
310 ------=_nmh-multipart-3
311 Content-Type: text/html; charset="Windows-1252"
312 Content-Transfer-Encoding: 7bit
316 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
317 <meta name="Generator" content="Microsoft Exchange Server">
318 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
321 ------=_nmh-multipart<br>
322 ------=_nmh-multipart-1<br>
323 ------=_nmh-multipart-2<br>
327 ------=_nmh-multipart-3--
330 cat >"`mhpath last`" <<EOF
332 From: sender@example.com
333 To: bonquiqui@example.com
335 Date: Sat, 26 Jan 2013 17:37:53 -0500
336 Content-Type: text/html; charset="Windows-1252"
337 Content-Transfer-Encoding: quoted-printable
341 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
343 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
344 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
345 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
348 ------=3D_nmh-multipart<br>
349 ------=3D_nmh-multipart-1<br>
350 ------=3D_nmh-multipart-2<br>
355 if [ $can_reformat_texthtml -eq 1 ]; then
356 printf '%s\n' "mhfixmsg: 12, insert text/plain part
357 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
360 #### lynx inserts multiple blank lines, so squeeze them.
361 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
362 squeeze_lines
>"$actual"
363 check
"$expected" "$actual" 'ignore space'
364 check
"$expected.err" "$actual.err"
370 # check -nodecodetext
371 start_test
"-nodecodetext"
372 prepare_space
>"$expected" <<EOF
374 From: sender@example.com
375 To: bonquiqui@example.com
377 Date: Sat, 26 Jan 2013 17:37:53 -0500
378 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
380 ------=_nmh-multipart
381 Content-Type: text/plain; charset="Windows-1252"
382 Content-Transfer-Encoding: 7bit
384 Need to go! Need ... to ... go!
386 ------=_nmh-multipart
387 Content-Type: text/html; charset="Windows-1252"
388 Content-Transfer-Encoding: quoted-printable
392 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
394 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
395 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
396 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
400 <div>Need to go! Need ... to ... go!</div>
404 ------=_nmh-multipart--
407 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
409 From: sender@example.com
410 To: bonquiqui@example.com
412 Date: Sat, 26 Jan 2013 17:37:53 -0500
413 Content-Type: text/html; charset="Windows-1252"
414 Content-Transfer-Encoding: quoted-printable
418 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
420 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
421 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
422 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
426 <div>Need to go! Need ... to ... go!</div>
431 if [ $can_reformat_texthtml -eq 1 ]; then
432 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
434 #### lynx inserts multiple blank lines, so squeeze them.
435 run_prog mhfixmsg last
-nodecodetext -outfile - -verbose 2>"$actual.err" | \
436 squeeze_lines
>"$actual"
437 check
"$expected" "$actual" 'ignore space'
438 check
"$expected.err" "$actual.err"
444 # check -decodetext (enabled by default)
445 start_test
"-decodetext (enabled by default)"
446 cat >"$expected" <<EOF
447 To: recipient@example.com
448 From: sender@example.com
449 Subject: mhfixmsg decode test 1
451 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
453 ------- =_aaaaaaaaaa0
454 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
455 Content-Disposition: attachment; filename="test4.txt"
456 Content-Transfer-Encoding: 7bit
458 This is a text/plain part.
460 ------- =_aaaaaaaaaa0--
463 cat >"`mhpath new`" <<EOF
464 To: recipient@example.com
465 From: sender@example.com
466 Subject: mhfixmsg decode test 1
468 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
470 ------- =_aaaaaaaaaa0
471 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
472 Content-Disposition: attachment; filename="test4.txt"
473 Content-Transfer-Encoding: base64
475 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
477 ------- =_aaaaaaaaaa0--
480 run_prog mhfixmsg last
-outfile "$actual"
481 check
"$expected" "$actual"
484 # check -decodetext with more complicated content structure
485 start_test
"-decodetext with more complicated content structure"
487 To: recipient@example.com
488 From: sender@example.com
489 Subject: mhfixmsg decode test 2
491 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
493 This is additional content before the first subpart of the multipart.
495 ------- =_aaaaaaaaaa0
496 Content-Type: multipart/related;
497 type="text/plain"; boundary="subpart__1.1"
500 Content-Type: text/plain; charset="iso-8859-1"
501 Content-Disposition: attachment; filename="test1.txt"
503 This is the first text/plain part, in a subpart.
507 This is additional content after the last subpart of the multipart.
509 ------- =_aaaaaaaaaa0
510 Content-Type: text/plain; charset="iso-8859-1"
511 Content-Disposition: attachment; filename="test2.txt"
512 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
513 Content-Transfer-Encoding: 7bit
515 This is the second text/plain part.
517 ------- =_aaaaaaaaaa0
518 Content-Type: text/plain; charset="iso-8859-1"
519 Content-Disposition: attachment; filename="test3.txt"
521 This is the third text/plain part.
523 ------- =_aaaaaaaaaa0
524 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
525 Content-Disposition: attachment; filename="test4.txt"
526 Content-Transfer-Encoding: 7bit
528 This is the fourth text/plain part.
530 ------- =_aaaaaaaaaa0--
532 This is additional content after the last subpart of the multipart.
535 cat >"`mhpath new`" <<EOF
536 To: recipient@example.com
537 From: sender@example.com
538 Subject: mhfixmsg decode test 2
540 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
542 This is additional content before the first subpart of the multipart.
544 ------- =_aaaaaaaaaa0
545 Content-Type: multipart/related;
546 type="text/plain"; boundary="subpart__1.1"
549 Content-Type: text/plain; charset="iso-8859-1"
550 Content-Disposition: attachment; filename="test1.txt"
552 This is the first text/plain part, in a subpart.
556 This is additional content after the last subpart of the multipart.
558 ------- =_aaaaaaaaaa0
559 Content-Type: text/plain; charset="iso-8859-1"
560 Content-Disposition: attachment; filename="test2.txt"
561 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
562 Content-Transfer-Encoding: quoted-printable
564 This is the second text/plain part.
566 ------- =_aaaaaaaaaa0
567 Content-Type: text/plain; charset="iso-8859-1"
568 Content-Disposition: attachment; filename="test3.txt"
570 This is the third text/plain part.
572 ------- =_aaaaaaaaaa0
573 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
574 Content-Disposition: attachment; filename="test4.txt"
575 Content-Transfer-Encoding: base64
577 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
579 ------- =_aaaaaaaaaa0--
581 This is additional content after the last subpart of the multipart.
583 run_prog mhfixmsg last
-outfile "$actual"
584 check
"$expected" "$actual"
587 # check attempted (default, 8 bit) -decodetext of binary text
588 #### Generated the encoded text below with:
589 #### $ printf '\275\262=\274\000\n' | base64
590 start_test
"attempted (default, 8 bit) -decodetext of binary text"
591 cat >"`mhpath new`" <<EOF
592 To: recipient@example.com
593 From: sender@example.com
594 Subject: mhfixmsg binary decode test
596 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
598 ------- =_aaaaaaaaaa0
599 Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
600 Content-Transfer-Encoding: base64
604 ------- =_aaaaaaaaaa0--
607 cp -p "`mhpath last`" "$expected"
608 run_prog mhfixmsg last
609 check
"`mhpath last`" "$expected" 'keep first'
612 # check for successful decode of a different part with attempted -decodetext
613 # of binary (>998 characters) text
614 start_test
"for successful decode of a different part with attempted -decodetext"
616 To: recipient@example.com
617 From: sender@example.com
618 Subject: mhfixmsg successful decode of text/plain with failed binary decode
620 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
622 ------- =_aaaaaaaaaa0
623 Content-Type: text/plain; charset="iso-8859-1"
624 Content-Transfer-Encoding: 7bit
626 This is a text plain part
628 ------- =_aaaaaaaaaa0
629 Content-Type: text/html; charset="ascii"
630 Content-Transfer-Encoding: base64
631 Content-Disposition: inline
633 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
634 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
635 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
636 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
637 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
638 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
639 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
640 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
641 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
642 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
643 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
644 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
645 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
646 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
647 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
648 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
649 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
650 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
651 ICA8L2JvZHk+PC9odG1sPg==
653 ------- =_aaaaaaaaaa0--
656 cat >"`mhpath new`" <<EOF
657 To: recipient@example.com
658 From: sender@example.com
659 Subject: mhfixmsg successful decode of text/plain with failed binary decode
661 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
663 ------- =_aaaaaaaaaa0
664 Content-Type: text/plain; charset="iso-8859-1"
665 Content-Transfer-Encoding: base64
667 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
669 ------- =_aaaaaaaaaa0
670 Content-Type: text/html; charset="ascii"
671 Content-Transfer-Encoding: base64
672 Content-Disposition: inline
674 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
675 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
676 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
677 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
678 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
679 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
680 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
681 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
682 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
683 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
684 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
685 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
686 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
687 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
688 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
689 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
690 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
691 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
692 ICA8L2JvZHk+PC9odG1sPg==
694 ------- =_aaaaaaaaaa0--
697 run_prog mhfixmsg
-noreformat last
698 check
"`mhpath last`" "$expected" 'keep first'
701 # check for successful decode of a different part with -decodetext of binary
702 # (>998 characters) text
703 start_test
"for successful decode of a different part with -decodetext of binary"
705 To: recipient@example.com
706 From: sender@example.com
707 Subject: mhfixmsg successful decode of text/plain with failed binary decode
709 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
710 Content-Transfer-Encoding: binary
712 ------- =_aaaaaaaaaa0
713 Content-Type: text/plain; charset="iso-8859-1"
714 Content-Transfer-Encoding: 7bit
716 This is a text plain part
718 ------- =_aaaaaaaaaa0
719 Content-Type: text/html; charset="ascii"
720 Content-Transfer-Encoding: binary
721 Content-Disposition: inline
723 <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>
725 ------- =_aaaaaaaaaa0--
728 run_prog mhfixmsg
-noreformat -decodetext binary last
729 check
"`mhpath last`" "$expected"
732 # check -decodetext of binary (containing ASCII NUL) text
733 start_test
"-decodetext of binary (containing ASCII NUL) text"
734 printf "%s\275\262=\274\000%s" "To: recipient@example.com
735 From: sender@example.com
736 Subject: mhfixmsg binary decode test
738 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
739 Content-Transfer-Encoding: binary
741 ------- =_aaaaaaaaaa0
742 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
743 Content-Transfer-Encoding: binary
747 ------- =_aaaaaaaaaa0--
749 mhfixmsg last
-decodetext binary
-outfile "$actual"
750 check
"$expected" "$actual"
753 # check that -reformat succeeds when decode of binary text fails
754 start_test
"-reformat succeeds when decode of binary text fails"
755 prepare_space
>"$expected" <<'EOF'
757 Date: Thu, 11 Apr 2013 02:47:08 -0700
759 From: <sender@example.com>
760 Subject: body requires binary encoding
761 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
763 ------=_nmh-multipart
764 Content-Type: text/plain; charset="ISO-8859-1"
765 Content-Transfer-Encoding: 7bit
770 Vehicle License Fee $1.84
773 ------=_nmh-multipart
774 Content-Type: text/html; charset="ISO-8859-1"
775 Content-Transfer-Encoding: quoted-printable
780 cat >"`mhpath new`" <<'EOF'
782 Content-Type: text/html; charset="ISO-8859-1"
783 Content-Transfer-Encoding: quoted-printable
784 Date: Thu, 11 Apr 2013 02:47:08 -0700
786 From: <sender@example.com>
787 Subject: body requires binary encoding
790 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
791 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
792 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
793 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
794 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
795 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
796 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
797 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
798 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
799 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
800 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
801 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
802 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
803 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
804 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
805 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
806 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
807 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
808 #333333" size=3D"2">$6.00</font></td></tr>
814 if [ $can_reformat_texthtml -eq 1 ]; then
815 #### lynx inserts multiple blank lines, so squeeze them.
816 #### Truncate to avoid comparing the html portion because it can
817 #### get reformatted.
818 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
819 check
"$expected" "$actual" 'ignore space'
821 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
827 # Also checks preservation of attributes after one (charset) that is
829 start_test
"-textcharset"
830 cat >"$expected" <<EOF
831 To: recipient@example.com
832 From: sender@example.com
833 Subject: mhfixmsg textcharset test
835 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
836 Content-Transfer-Encoding: 8bit
838 ------- =_aaaaaaaaaa0
839 Content-Type: text/plain; charset="utf-8"; name="square.txt"
840 Content-Disposition: attachment; filename="square.txt"
841 Content-Transfer-Encoding: 8bit
845 ------- =_aaaaaaaaaa0--
848 #### Generated the encoded text below with:
849 #### $ printf '\275\262=\274\n' | base64
850 cat >"`mhpath new`" <<EOF
851 To: recipient@example.com
852 From: sender@example.com
853 Subject: mhfixmsg textcharset test
855 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
857 ------- =_aaaaaaaaaa0
858 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
859 Content-Disposition: attachment; filename="square.txt"
860 Content-Transfer-Encoding: base64
864 ------- =_aaaaaaaaaa0--
867 if test "$ICONV_ENABLED" -eq 1; then
868 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
869 check
"$expected" "$actual"
871 echo "$0: skipping -textcharset check because nmh was built without iconv"
876 # check -nofixboundary
877 start_test
"-nofixboundary"
878 cat >"$expected" <<EOF
881 cat >"`mhpath new`" <<EOF
882 Date: Fri, 13 May 2011 08:21:12 -0500
883 Content-Type: multipart/alternative;
884 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
885 Content-Transfer-Encoding: 8bit
887 From: <sender@example.com>
888 To: <recipient@example.com>
889 Subject: mhfixmsg bad boundary test
891 This is a multi-part message in MIME format.
893 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
894 Content-Type: text/plain
896 The boundaries of this part don't match the header boundary.
898 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
901 cp -p "`mhpath last`" "`mhpath new`"
903 run_test
'mhfixmsg last -nofixboundary' ''
904 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
907 # check that message is not output when fed through stdin (without -outfile)
908 start_test
"message is not output when fed through stdin"
909 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
910 check
"$expected" "$actual"
911 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
912 "$actual.err" >/dev
/null
; then
915 echo "$0: test failed, output is in $actual.err."
916 failed
=`expr ${failed:-0} + 1`
920 # check fixup of erroneous boundary in multipart (-fixboundary,
921 # enabled by default)
923 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
924 cat >"$expected" <<EOF
925 Date: Fri, 13 May 2011 08:21:12 -0500
926 Content-Type: multipart/alternative;
927 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
928 Content-Transfer-Encoding: 8bit
930 From: <sender@example.com>
931 To: <recipient@example.com>
932 Subject: mhfixmsg bad boundary test
934 This is a multi-part message in MIME format.
936 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
937 Content-Type: text/plain
939 The boundaries of this part don't match the header boundary.
941 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
944 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
945 "mhfixmsg: 18, fix multipart boundary"
946 check
"$expected" "$actual"
949 # check that message is not modified when -fixboundary fails
950 start_test
"message is not modified when -fixboundary fails"
951 cat >"`mhpath new`" <<EOF
952 Date: Fri, 13 May 2011 08:21:12 -0500
953 Content-Type: multipart/alternative;
954 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
955 Content-Transfer-Encoding: 8bit
957 From: <sender@example.com>
958 To: <recipient@example.com>
959 Subject: mhfixmsg bad boundary test
961 This is a multi-part message in MIME format.
963 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
964 Content-Type: text/plain
966 The boundary below doesn't match the header boundary.
969 NextPart_000_1781A1A_01CC1147.81EBA8D4--
972 cp -p "`mhpath last`" "$expected"
973 run_test
"mhfixmsg last -outfile $actual" ''
974 check
"$expected" "$actual"
977 # check that text/plain part is not added to text/html in multipart/related
978 # when it shouldn't be
979 start_test
"text/plain part is not added to text/html in multipart/related when it shouldn't be"
980 cat >"`mhpath new`" <<EOF
982 Date: Tue, 26 Feb 2013 18:07:20 -0600
983 Subject: multipart/related, not /alternative
984 Content-Type: multipart/related;
985 type="text/html"; boundary="----=_Part_90310_101292502.1"
987 ------=_Part_90310_101292502.1
988 Content-Type: text/html; charset="us-ascii"
989 Content-Transfer-Encoding: 7bit
992 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
993 <title>HTML Content</title>
996 This is the real content.
1000 ------=_Part_90310_101292502.1
1001 Content-Type: text/plain; charset="us-ascii"
1002 Content-Transfer-Encoding: 7bit
1004 Your email client does not support HTML messages
1006 ------=_Part_90310_101292502.1--
1009 cp -p "`mhpath last`" "$expected"
1011 if [ $can_reformat_texthtml -eq 1 ]; then
1012 #### lynx inserts multiple blank lines, so squeeze them.
1013 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1014 check
"$expected" "$actual" 'ignore space'
1020 # check that text/plain part is added to text/html in multipart/related
1022 start_test
"text/plain part is added to text/html in multipart/related when it should be"
1023 cat >"$expected" <<EOF
1025 Date: Tue, 26 Feb 2013 18:07:20 -0600
1026 Subject: multipart/related, not /alternative
1027 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1029 ------=_Part_90310_101292502.1
1030 Content-Type: text/plain; charset="us-ascii"
1031 Content-Transfer-Encoding: 7bit
1033 This is the real content.
1035 ------=_Part_90310_101292502.1
1036 Content-Type: text/html; charset="us-ascii"
1037 Content-Transfer-Encoding: 7bit
1040 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1041 <title>HTML Content</title>
1044 This is the real content.
1048 ------=_Part_90310_101292502.1--
1051 cat >"`mhpath new`" <<EOF
1053 Date: Tue, 26 Feb 2013 18:07:20 -0600
1054 Subject: multipart/related, not /alternative
1055 Content-Type: multipart/related;
1056 type="text/html"; boundary="----=_Part_90310_101292502.1"
1058 ------=_Part_90310_101292502.1
1059 Content-Type: text/html; charset="us-ascii"
1060 Content-Transfer-Encoding: 7bit
1063 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1064 <title>HTML Content</title>
1067 This is the real content.
1071 ------=_Part_90310_101292502.1--
1074 if [ $can_reformat_texthtml -eq 1 ]; then
1075 #### lynx inserts multiple blank lines, so squeeze them.
1076 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1077 check
"$expected" "$actual" 'ignore space'
1083 # check handling of rfc822 message type
1084 # also, checks -fixboundary
1085 start_test
"handling of rfc822 message type"
1086 cat >"$expected" <<EOF
1087 From: Test <test@example.com>
1088 To: Some User <user@example.com>
1089 Date: Fri, 29 Sep 2006 00:00:00
1090 Message-Id: @test.nmh
1091 Subject: message with message/rfc822 attachment
1093 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1095 and some garbage before the attachment
1097 ------- =_aaaaaaaaaa0
1098 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1099 Content-Description: 1552
1100 Content-Disposition: attachment; filename="1552"
1102 From: Test <test@example.com>
1103 To: <another_user@example.com>
1104 Date: Thu, 28 Sep 2006 00:00:00
1105 Message-Id: @test.nmh
1106 Subject: message/rfc822 attachment
1108 This is an RFC-822 message.
1110 ------- =_aaaaaaaaaa0--
1112 and some garbage at the end
1115 cat >"`mhpath new`" <<EOF
1116 From: Test <test@example.com>
1117 To: Some User <user@example.com>
1118 Date: Fri, 29 Sep 2006 00:00:00
1119 Message-Id: @test.nmh
1120 Subject: message with message/rfc822 attachment
1122 Content-Type: multipart/mixed; boundary="----- =badboundary"
1124 and some garbage before the attachment
1126 ------- =_aaaaaaaaaa0
1127 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1128 Content-Description: 1552
1129 Content-Disposition: attachment; filename="1552"
1131 From: Test <test@example.com>
1132 To: <another_user@example.com>
1133 Date: Thu, 28 Sep 2006 00:00:00
1134 Message-Id: @test.nmh
1135 Subject: message/rfc822 attachment
1137 This is an RFC-822 message.
1139 ------- =_aaaaaaaaaa0--
1141 and some garbage at the end
1144 run_test
'mhfixmsg last -outfile '"$actual" ''
1145 check
"$expected" "$actual"
1148 # check not stripping of CRs from ASCII text context (default)
1149 start_test
"not stripping of CRs from ASCII text context (default)"
1150 cat >"$expected" <<EOF
1152 From: sender@example.com
1153 To: recipient@example.com
1154 Subject: message with CR's
1155 Date: Mon, 29 Apr 2013 11:51:45 -0400
1157 There are two CR-LF pairs at the end of this sentence.
1161 cat >"`mhpath new`" <<'EOF'
1163 From: sender@example.com
1164 To: recipient@example.com
1165 Subject: message with CR's
1166 Date: Mon, 29 Apr 2013 11:51:45 -0400
1168 There are two CR-LF pairs at the end of this sentence.
1172 run_prog mhfixmsg last
-outfile "$actual"
1173 check
"$expected" "$actual"
1176 # check stripping of CRs from ASCII text context
1177 start_test
"stripping of CRs from ASCII text context"
1178 cat >"$expected" <<EOF
1180 From: sender@example.com
1181 To: recipient@example.com
1182 Subject: message with CR's
1183 Date: Mon, 29 Apr 2013 11:51:45 -0400
1185 There were two CR-LF pairs at the end of this sentence.
1189 cat >"`mhpath new`" <<'EOF'
1191 From: sender@example.com
1192 To: recipient@example.com
1193 Subject: message with CR's
1194 Date: Mon, 29 Apr 2013 11:51:45 -0400
1196 There were two CR-LF pairs at the end of this sentence.
1200 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1201 check
"$expected" "$actual"
1204 # check -replacetextplain
1205 start_test
"-replacetextplain"
1206 prepare_space
>"$expected" <<EOF
1207 To: recipient@example.com
1208 From: sender@example.com
1209 Subject: mhfixmsg replacement of bad text/plain part test
1211 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1214 Content-Type: text/plain; charset="UTF-8"
1215 Content-Transfer-Encoding: 7bit
1217 Yes, the text/plain part really was empty.
1220 Content-Type: text/html; charset="UTF-8"
1221 Content-Disposition: inline
1224 <title>eticket</title>
1227 Yes, the text/plain part really was empty.
1231 ------=_Part_876302--
1234 cat >"`mhpath new`" <<'EOF'
1235 To: recipient@example.com
1236 From: sender@example.com
1237 Subject: mhfixmsg replacement of bad text/plain part test
1239 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1242 Content-Type: text/plain; charset="iso-8859-15"
1243 Content-Transfer-Encoding: 7bit
1244 Content-Disposition: inline
1249 Content-Type: text/html; charset="UTF-8"
1250 Content-Disposition: inline
1253 <title>eticket</title>
1256 Yes, the text/plain part really was empty.
1260 ------=_Part_876302--
1263 if [ $can_reformat_texthtml -eq 1 ]; then
1264 #### lynx inserts multiple blank lines, so squeeze them.
1265 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1266 squeeze_lines
> "$actual"
1267 check
"$expected" "$actual" 'ignore space'
1273 # check -noreplacetextplain
1274 start_test
"-noreplacetextplain"
1275 cat >"$expected" <<EOF
1276 To: recipient@example.com
1277 From: sender@example.com
1278 Subject: mhfixmsg replacement of bad text/plain part test
1280 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1283 Content-Type: text/plain; charset="iso-8859-15"
1284 Content-Transfer-Encoding: 7bit
1285 Content-Disposition: inline
1290 Content-Type: text/html; charset="UTF-8"
1291 Content-Disposition: inline
1294 <title>eticket</title>
1297 Yes, the text/plain part really was empty.
1301 ------=_Part_876302--
1304 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1305 check
"$expected" "$actual"
1308 # check removal of extraneous trailing semicolon from header parameter list
1309 start_test
"removal of extraneous trailing semicolon from header parameter list"
1310 cat >"$expected" <<EOF
1311 To: recipient@example.com
1313 From: sender@example.com
1315 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1317 ------- =_aaaaaaaaaa0
1318 Content-Type: text/plain; charset="us-ascii"
1322 ------- =_aaaaaaaaaa0
1323 Content-Type: text/plain; charset="us-ascii";
1325 Content-Description: check folded headers, with and without trailing semicolon
1326 Content-Disposition: attachment;
1331 ------- =_aaaaaaaaaa0--
1334 cat >"`mhpath new`" <<EOF
1335 To: recipient@example.com
1337 From: sender@example.com
1339 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1341 ------- =_aaaaaaaaaa0
1342 Content-Type: text/plain; charset="us-ascii";
1346 ------- =_aaaaaaaaaa0
1347 Content-Type: text/plain; charset="us-ascii";
1349 Content-Description: check folded headers, with and without trailing semicolon
1350 Content-Disposition: attachment;
1355 ------- =_aaaaaaaaaa0--
1357 run_test
'mhfixmsg last -outfile '"$actual" ''
1358 check
"$expected" "$actual"
1361 if [ $can_reformat_texthtml -eq 1 ]; then
1363 start_test
"rmmproc"
1364 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1367 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1368 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1369 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1371 run_test
'mhfixmsg 16' ''
1372 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1373 "${MH_TEST_DIR}/Mail/inbox/16.original"
1377 start_test
"-normmproc"
1378 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1380 run_test
'mhfixmsg 21 -normmproc'
1381 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1382 "${MH_TEST_DIR}/Mail/inbox/${sbackup}21" 'keep first'
1387 start_test
"-rmmproc"
1388 run_test
'mhfixmsg 21 -rmmproc true'
1389 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1390 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1391 failed
=`expr ${failed:-0} + 1`
1396 start_test
"-fixtype"
1397 cat >"$expected" <<EOF
1398 To: recipient@example.com
1399 From: sender@example.com
1400 Subject: mhfixmsg with incorrect Content-Type
1402 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1404 ------- =_aaaaaaaaaa0
1405 Content-Type: text/plain; name="plaintext.txt"
1409 ------- =_aaaaaaaaaa0--
1412 cat >"`mhpath new`" <<EOF
1413 To: recipient@example.com
1414 From: sender@example.com
1415 Subject: mhfixmsg with incorrect Content-Type
1417 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1419 ------- =_aaaaaaaaaa0
1420 Content-Type: application/octet-stream; name="plaintext.txt"
1424 ------- =_aaaaaaaaaa0--
1427 mhfixmsg
-fixtype application
/octet
-stream last
1428 check
"$expected" "`mhpath last`"
1431 # check default -decodetypes
1432 start_test
"default -decodetypes"
1433 cat >$expected <<EOF
1434 To: recipient@example.com
1435 From: sender@example.com
1436 Subject: mhfixmsg decode test 3
1438 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1440 ------- =_aaaaaaaaaa0
1441 Content-Type: text/plain; charset="iso-8859-1"
1442 Content-Disposition: attachment; filename="test1.txt"
1443 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1444 Content-Transfer-Encoding: 7bit
1446 This is the text/plain part.
1448 ------- =_aaaaaaaaaa0
1449 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1450 Content-Disposition: attachment; filename="test2.txt"
1451 Content-Transfer-Encoding: 7bit
1455 This was the text/html part.
1460 ------- =_aaaaaaaaaa0--
1463 cat >"`mhpath new`" <<EOF
1464 To: recipient@example.com
1465 From: sender@example.com
1466 Subject: mhfixmsg decode test 3
1468 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1470 ------- =_aaaaaaaaaa0
1471 Content-Type: text/plain; charset="iso-8859-1"
1472 Content-Disposition: attachment; filename="test1.txt"
1473 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1474 Content-Transfer-Encoding: quoted-printable
1476 This is the text/plain part.
1478 ------- =_aaaaaaaaaa0
1479 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1480 Content-Disposition: attachment; filename="test2.txt"
1481 Content-Transfer-Encoding: base64
1483 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1484 Ym9keT4KPC9odG1sPgo=
1486 ------- =_aaaaaaaaaa0--
1488 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1489 check
"$expected" "$actual"
1492 # check -decodetypes text/plain
1493 start_test
"-decodetypes text/plain"
1494 cat >$expected <<EOF
1495 To: recipient@example.com
1496 From: sender@example.com
1497 Subject: mhfixmsg decode test 4
1499 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1501 ------- =_aaaaaaaaaa0
1502 Content-Type: text/plain; charset="iso-8859-1"
1503 Content-Disposition: attachment; filename="test1.txt"
1504 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1505 Content-Transfer-Encoding: 7bit
1507 This is the text/plain part.
1509 ------- =_aaaaaaaaaa0
1510 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1511 Content-Disposition: attachment; filename="test2.txt"
1512 Content-Transfer-Encoding: base64
1514 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1515 CjwvYm9keT4NCjwvaHRtbD4NCg==
1517 ------- =_aaaaaaaaaa0--
1520 cat >"`mhpath new`" <<EOF
1521 To: recipient@example.com
1522 From: sender@example.com
1523 Subject: mhfixmsg decode test 4
1525 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1527 ------- =_aaaaaaaaaa0
1528 Content-Type: text/plain; charset="iso-8859-1"
1529 Content-Disposition: attachment; filename="test1.txt"
1530 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1531 Content-Transfer-Encoding: quoted-printable
1533 This is the text/plain part.
1535 ------- =_aaaaaaaaaa0
1536 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1537 Content-Disposition: attachment; filename="test2.txt"
1538 Content-Transfer-Encoding: base64
1540 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1541 CjwvYm9keT4NCjwvaHRtbD4NCg==
1543 ------- =_aaaaaaaaaa0--
1545 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1546 check
"$expected" "$actual"
1549 # check -decodetypes attachment/ics
1550 start_test
"-decodetypes attachment/ics"
1551 cat >$expected <<EOF
1552 To: recipient@example.com
1553 From: sender@example.com
1554 Subject: mhfixmsg decode test 5
1556 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1558 ------- =_aaaaaaaaaa0
1559 Content-Type: text/plain; charset="iso-8859-1"
1560 Content-Disposition: attachment; filename="test1.txt"
1561 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1562 Content-Transfer-Encoding: 7bit
1564 This is the text/plain part.
1566 ------- =_aaaaaaaaaa0
1567 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1568 Content-Disposition: attachment; filename="invite.ics"
1569 Content-Transfer-Encoding: 7bit
1575 DTSTAMP:20150101T162400Z
1576 DTSTART:20150105T160000
1577 DTEND:20150105T163000
1578 SUMMARY:4 pm meeting
1582 ------- =_aaaaaaaaaa0--
1585 cat >"`mhpath new`" <<EOF
1586 To: recipient@example.com
1587 From: sender@example.com
1588 Subject: mhfixmsg decode test 5
1590 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1592 ------- =_aaaaaaaaaa0
1593 Content-Type: text/plain; charset="iso-8859-1"
1594 Content-Disposition: attachment; filename="test1.txt"
1595 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1596 Content-Transfer-Encoding: quoted-printable
1601 ------- =_aaaaaaaaaa0
1602 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1603 Content-Disposition: attachment; filename="invite.ics"
1604 Content-Transfer-Encoding: base64
1606 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1607 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1608 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1609 CkVORDpWQ0FMRU5EQVINCg==
1611 ------- =_aaaaaaaaaa0--
1613 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1614 check
"$expected" "$actual"
1617 # check -decodetypes attachment/ics and -nocrlflinebreaks
1618 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1619 cat >$expected <<EOF
1620 To: recipient@example.com
1621 From: sender@example.com
1622 Subject: mhfixmsg decode test 5
1624 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1626 ------- =_aaaaaaaaaa0
1627 Content-Type: text/plain; charset="iso-8859-1"
1628 Content-Disposition: attachment; filename="test1.txt"
1629 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1630 Content-Transfer-Encoding: 7bit
1632 This is the text/plain part.
1634 ------- =_aaaaaaaaaa0
1635 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1636 Content-Disposition: attachment; filename="invite.ics"
1637 Content-Transfer-Encoding: 7bit
1643 DTSTAMP:20150101T162400Z
1644 DTSTART:20150105T160000
1645 DTEND:20150105T163000
1646 SUMMARY:4 pm meeting
1650 ------- =_aaaaaaaaaa0--
1653 cat >"`mhpath new`" <<EOF
1654 To: recipient@example.com
1655 From: sender@example.com
1656 Subject: mhfixmsg decode test 5
1658 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1660 ------- =_aaaaaaaaaa0
1661 Content-Type: text/plain; charset="iso-8859-1"
1662 Content-Disposition: attachment; filename="test1.txt"
1663 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1664 Content-Transfer-Encoding: quoted-printable
1669 ------- =_aaaaaaaaaa0
1670 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1671 Content-Disposition: attachment; filename="invite.ics"
1672 Content-Transfer-Encoding: base64
1674 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1675 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1676 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1677 CkVORDpWQ0FMRU5EQVINCg==
1679 ------- =_aaaaaaaaaa0--
1681 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1682 check
"$expected" "$actual"
1685 # check that input is passed through to output when there's a parse error
1686 # (the charset string is missing its closing quote) with -outfile
1687 start_test
"input is passed through to output when there's a parse error"
1688 cat >"$expected.err" <<EOF
1689 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1691 mhfixmsg: unable to parse message 31
1694 cat >"`mhpath new`" <<EOF
1695 To: recipient@example.com
1696 From: sender@example.com
1697 Subject: mhfixmsg pass through on parse error
1699 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1701 ------- =_aaaaaaaaaa0
1702 Content-Type: text/plain; charset="iso-8859-1
1703 Content-Disposition: attachment; filename="test1.txt"
1704 Content-Transfer-Encoding: quoted-printable
1709 ------- =_aaaaaaaaaa0--
1712 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1714 #### Expected output is identical to the input message.
1715 check
"`mhpath last`" "$actual" 'keep first'
1716 check
"$expected.err" "$actual.err"
1719 # check that input is passed through to output when there's a parse error
1720 # (the charset string is missing its closing quote) with -outfile, and
1721 # input from stdin. Don't check err output, because it contains the name
1722 # of a tmp file. It's similar to that of the previous check.
1723 start_test
"input is passed through to output when there's a parse error"
1725 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1727 #### Expected output is identical to the input message.
1728 check
"`mhpath last`" "$actual" 'keep first'
1731 start_test
"pass through message with relative folder path with parse error"
1732 #### Factor out leading portion of current folder path and make it relative.
1735 run_prog mhfixmsg
+.
/`mhpath | sed "s%^$pwd/%%"` last
-out - >"$actual" 2>/dev
/null
1737 folder
-f +inbox
>/dev
/null
1738 #### Expected output is identical to the input message.
1739 check
"`mhpath last`" "$actual"
1742 start_test
"fix RFC 2047 encoded header parameters"
1743 #### Also, add C-T-E:8bit to the message headers.
1744 cat >"$expected" <<EOF
1745 To: recipient@example.com
1746 From: sender@example.com
1747 Date: Wed, 28 Sep 2016 11:24:28 -0400
1748 Subject: invalid header parameter encoding
1750 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1751 Content-Transfer-Encoding: 8bit
1753 --001a114dd3e8fe9c56053d92f414
1754 Content-Type: text/plain; charset=UTF-8
1758 --001a114dd3e8fe9c56053d92f414
1759 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1760 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1761 Content-Transfer-Encoding: 8bit
1763 This is the first text/plain part, in a subpart. The file name
1766 --001a114dd3e8fe9c56053d92f414--
1769 cat >"`mhpath new`" <<EOF
1770 To: recipient@example.com
1771 From: sender@example.com
1772 Date: Wed, 28 Sep 2016 11:24:28 -0400
1773 Subject: invalid header parameter encoding
1775 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1777 --001a114dd3e8fe9c56053d92f414
1778 Content-Type: text/plain; charset=UTF-8
1782 --001a114dd3e8fe9c56053d92f414
1783 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1784 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1785 Content-Transfer-Encoding: 8bit
1787 This is the first text/plain part, in a subpart. The file name
1790 --001a114dd3e8fe9c56053d92f414--
1792 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1793 check
"$expected" "$actual"
1796 start_test
"-nodecodeheaderfieldbodies"
1797 cat >"`mhpath new`" <<EOF
1798 To: recipient@example.com
1799 From: sender@example.com
1800 Date: Wed, 28 Sep 2016 11:24:28 -0400
1801 Subject: =?utf-8?B?dGhpcyBTdWJqZWN0IHdhcyBVVEYtOCBlbmNvZGVk?=
1803 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1804 Content-Transfer-Encoding: 8bit
1806 --001a114dd3e8fe9c56053d92f414
1807 Content-Type: text/plain; charset=UTF-8
1811 --001a114dd3e8fe9c56053d92f414
1812 Content-Type: text/plain; charset=UTF-8; name="test.txt"
1813 Content-Disposition: attachment; filename="test.txt"
1814 Content-Transfer-Encoding: 8bit
1816 This is the first text/plain part, in a subpart. The file name
1819 --001a114dd3e8fe9c56053d92f414--
1821 run_prog mhfixmsg
-file - -outfile - -decodeheaderfieldbodies utf
-8 \
1822 -nodecodeheaderfieldbodies <`mhpath last` >"$actual" 2>/dev
/null
1823 check
`mhpath last` "$actual" 'keep first'
1826 start_test
"test decoding of UTF-8 header value"
1827 cat >"$expected" <<EOF
1828 To: recipient@example.com
1829 From: sender@example.com
1830 Date: Wed, 28 Sep 2016 11:24:28 -0400
1831 Subject: this Subject was UTF-8 encoded
1833 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1834 Content-Transfer-Encoding: 8bit
1836 --001a114dd3e8fe9c56053d92f414
1837 Content-Type: text/plain; charset=UTF-8
1841 --001a114dd3e8fe9c56053d92f414
1842 Content-Type: text/plain; charset=UTF-8; name="test.txt"
1843 Content-Disposition: attachment; filename="test.txt"
1844 Content-Transfer-Encoding: 8bit
1846 This is the first text/plain part, in a subpart. The file name
1849 --001a114dd3e8fe9c56053d92f414--
1852 run_prog mhfixmsg
-file - -outfile - -decodeheaderfieldbodies utf
-8 \
1853 <`mhpath last` >"$actual" 2>/dev
/null
1854 check
"$expected" "$actual"
1857 start_test
"-checkbase64 with base64 code that ends with == plus footer"
1858 cat >"`mhpath new`" <<EOF
1859 From: Test <test@example.com>
1860 Subject: base64 code that ends with ==
1862 Content-Type: text/plain
1863 Content-Transfer-Encoding: base64
1865 VGhpcyBpcyBzb21lIHRleHQuCg==
1868 Wait, this shouldn't be here.
1871 cat >"$expected" <<EOF
1872 From: Test <test@example.com>
1873 Subject: base64 code that ends with ==
1875 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
1877 ------=_nmh-multipart
1878 Content-Type: text/plain
1879 Content-Transfer-Encoding: 7bit
1883 ------=_nmh-multipart
1884 Content-Type: text/plain
1885 Content-Transfer-Encoding: 7bit
1888 Wait, this shouldn't be here.
1890 ------=_nmh-multipart--
1892 run_prog mhfixmsg last
-outfile "$actual"
1893 check
"$expected" "$actual"
1896 start_test
"-checkbase64 with -nodecodetext"
1897 cat >"`mhpath new`" <<EOF
1898 From: Test <test@example.com>
1899 Subject: base64 code that ends with ==
1901 Content-Type: text/plain
1902 Content-Transfer-Encoding: base64
1904 VGhpcyBpcyBzb21lIHRleHQuCg==
1907 Wait, this shouldn't be here.
1910 cat >"$expected" <<EOF
1911 From: Test <test@example.com>
1912 Subject: base64 code that ends with ==
1914 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
1916 ------=_nmh-multipart
1917 Content-Type: text/plain
1918 Content-Transfer-Encoding: base64
1920 VGhpcyBpcyBzb21lIHRleHQuCg==
1922 ------=_nmh-multipart
1923 Content-Type: text/plain
1924 Content-Transfer-Encoding: 7bit
1927 Wait, this shouldn't be here.
1929 ------=_nmh-multipart--
1931 run_prog mhfixmsg
-nodecodetext last
-outfile "$actual"
1932 check
"$expected" "$actual"
1935 start_test
"-checkbase64 with base64 code that ends with = plus footer"
1936 cat >"`mhpath new`" <<EOF
1937 From: Test <test@example.com>
1938 Subject: base64 code that ends with =
1940 Content-Type: text/plain
1941 Content-Transfer-Encoding: base64
1943 VGhpcyBpcyBwbGFpbiB0ZXh0Lgo=
1946 Wait, this shouldn't be here.
1949 cat >"$expected" <<EOF
1950 From: Test <test@example.com>
1951 Subject: base64 code that ends with =
1953 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
1955 ------=_nmh-multipart
1956 Content-Type: text/plain
1957 Content-Transfer-Encoding: 7bit
1961 ------=_nmh-multipart
1962 Content-Type: text/plain
1963 Content-Transfer-Encoding: 7bit
1966 Wait, this shouldn't be here.
1968 ------=_nmh-multipart--
1970 run_prog mhfixmsg last
-outfile "$actual"
1971 check
"$expected" "$actual"
1974 start_test
"-checkbase64 with base64 code that ends without = plus footer"
1975 cat >"`mhpath new`" <<EOF
1976 From: Test <test@example.com>
1977 Subject: base64 code that ends without =
1979 Content-Type: text/plain
1980 Content-Transfer-Encoding: base64
1982 VGhpcyBpcyBzb21lIHRleHQK
1985 Wait, this shouldn't be here.
1988 cat >"$expected" <<EOF
1989 From: Test <test@example.com>
1990 Subject: base64 code that ends without =
1992 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
1994 ------=_nmh-multipart
1995 Content-Type: text/plain
1996 Content-Transfer-Encoding: 7bit
2000 ------=_nmh-multipart
2001 Content-Type: text/plain
2002 Content-Transfer-Encoding: 7bit
2005 Wait, this shouldn't be here.
2007 ------=_nmh-multipart--
2009 run_prog mhfixmsg last
-outfile "$actual"
2010 check
"$expected" "$actual"
2013 start_test
"-checkbase64 with base64 code that contains single invalid character"
2014 cat >"`mhpath new`" <<EOF
2015 From: Test <test@example.com>
2016 Subject: base64 code that ends without =
2018 Content-Type: text/plain
2019 Content-Transfer-Encoding: base64
2021 VGhpcyBpcyBzb21lIHRleHQK
2024 Wait, this shouldn't be here.
2027 cat >"$expected" <<EOF
2028 From: Test <test@example.com>
2029 Subject: base64 code that ends without =
2031 Content-Type: text/plain
2032 Content-Transfer-Encoding: base64
2034 VGhpcyBpcyBzb21lIHRleHQK
2037 Wait, this shouldn't be here.
2040 cat >"$expected_err" <<EOF
2041 mhfixmsg: invalid base64 byte 0x2d: -X-
2042 Wait, this shouldn't be here.
2046 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual_err" || true
2047 check
"$expected" "$actual"
2048 check
"$expected_err" "$actual_err"
2051 start_test
"-checkbase64 with base64 code in MIME part"
2052 cat >"`mhpath new`" <<EOF
2053 From: Test <test@example.com>
2054 Subject: MIME part with base64 encoded text and unencoded footer
2056 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
2058 ------=_nmh-multipart
2059 Content-Type: text/plain
2060 Content-Transfer-Encoding: base64
2062 VGhpcyBpcyBzb21lIHRleHQK
2065 Wait, this shouldn't be here.
2067 ------=_nmh-multipart
2068 Content-Type: text/plain
2069 Content-Transfer-Encoding: 7bit
2071 This is a second text/plain part.
2073 ------=_nmh-multipart--
2076 cat >"$expected" <<EOF
2077 From: Test <test@example.com>
2078 Subject: MIME part with base64 encoded text and unencoded footer
2080 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
2082 ------=_nmh-multipart
2083 Content-Type: multipart/mixed; boundary="----=_nmh-multipart1"
2085 ------=_nmh-multipart1
2086 Content-Type: text/plain
2087 Content-Transfer-Encoding: 7bit
2091 ------=_nmh-multipart1
2092 Content-Type: text/plain
2093 Content-Transfer-Encoding: 7bit
2096 Wait, this shouldn't be here.
2098 ------=_nmh-multipart1--
2100 ------=_nmh-multipart
2101 Content-Type: text/plain
2102 Content-Transfer-Encoding: 7bit
2104 This is a second text/plain part.
2106 ------=_nmh-multipart--
2108 run_prog mhfixmsg last
-outfile "$actual"
2109 check
"$expected" "$actual"
2112 start_test
"-checkbase64 with 8-bit encoded base64 code"
2113 cat >"`mhpath new`" <<EOF
2114 From: Test <test@example.com>
2115 Subject: 8-bit encoded base64 code
2117 Content-Type: text/plain
2118 Content-Transfer-Encoding: base64
2120 U2VlIFJGQyAyMDQ1IMKnNi44Lg==
2123 Wait, this shouldn't be here.
2125 cat >"$expected" <<EOF
2126 From: Test <test@example.com>
2127 Subject: 8-bit encoded base64 code
2129 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
2130 Content-Transfer-Encoding: 8bit
2132 ------=_nmh-multipart
2133 Content-Type: text/plain
2134 Content-Transfer-Encoding: 8bit
2138 ------=_nmh-multipart
2139 Content-Type: text/plain
2140 Content-Transfer-Encoding: 7bit
2143 Wait, this shouldn't be here.
2145 ------=_nmh-multipart--
2148 run_prog mhfixmsg last
-outfile "$actual"
2149 check
"$expected" "$actual"
2152 # make sure there are no tmp files left over
2153 find "$MH_TEST_DIR/Mail" -name '*mhfix*' -print \
2155 cat >"$expected" <<EOF
2158 check
"$expected" "$actual"