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" 'keep first'
871 echo "$0: skipping -textcharset check because nmh was built without iconv"
876 # check -textcharset -verbose
877 start_test
"-textcharset -verbose"
878 cat >"$expected.err" <<EOF
879 mhfixmsg: 17 part 1, decode text/plain; charset="iso-8859-1"; name="square.txt"
880 mhfixmsg: 17 part 1, convert iso-8859-1 to utf-8
883 if test "$ICONV_ENABLED" -eq 1; then
884 run_prog mhfixmsg last
-textcharset utf-8
-outfile "$actual" -verbose \
886 check
"$expected" "$actual"
887 check
"$expected.err" "$actual.err"
889 echo "$0: skipping -textcharset -verbose check because nmh was built " \
891 rm -f "$expected" "$expected.err"
895 # check -nofixboundary
896 start_test
"-nofixboundary"
897 cat >"$expected" <<EOF
900 cat >"`mhpath new`" <<EOF
901 Date: Fri, 13 May 2011 08:21:12 -0500
902 Content-Type: multipart/alternative;
903 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
904 Content-Transfer-Encoding: 8bit
906 From: <sender@example.com>
907 To: <recipient@example.com>
908 Subject: mhfixmsg bad boundary test
910 This is a multi-part message in MIME format.
912 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
913 Content-Type: text/plain
915 The boundaries of this part don't match the header boundary.
917 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
920 cp -p "`mhpath last`" "`mhpath new`"
922 run_test
'mhfixmsg last -nofixboundary' ''
923 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
926 # check that message is not output when fed through stdin (without -outfile)
927 start_test
"message is not output when fed through stdin"
928 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
929 check
"$expected" "$actual"
930 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
931 "$actual.err" >/dev
/null
; then
934 echo "$0: test failed, output is in $actual.err."
935 failed
=`expr ${failed:-0} + 1`
939 # check fixup of erroneous boundary in multipart (-fixboundary,
940 # enabled by default)
942 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
943 cat >"$expected" <<EOF
944 Date: Fri, 13 May 2011 08:21:12 -0500
945 Content-Type: multipart/alternative;
946 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
947 Content-Transfer-Encoding: 8bit
949 From: <sender@example.com>
950 To: <recipient@example.com>
951 Subject: mhfixmsg bad boundary test
953 This is a multi-part message in MIME format.
955 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
956 Content-Type: text/plain
958 The boundaries of this part don't match the header boundary.
960 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
963 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
964 "mhfixmsg: 18, fix multipart boundary"
965 check
"$expected" "$actual"
968 # check that message is not modified when -fixboundary fails
969 start_test
"message is not modified when -fixboundary fails"
970 cat >"`mhpath new`" <<EOF
971 Date: Fri, 13 May 2011 08:21:12 -0500
972 Content-Type: multipart/alternative;
973 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
974 Content-Transfer-Encoding: 8bit
976 From: <sender@example.com>
977 To: <recipient@example.com>
978 Subject: mhfixmsg bad boundary test
980 This is a multi-part message in MIME format.
982 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
983 Content-Type: text/plain
985 The boundary below doesn't match the header boundary.
988 NextPart_000_1781A1A_01CC1147.81EBA8D4--
991 cp -p "`mhpath last`" "$expected"
992 run_test
"mhfixmsg last -outfile $actual" ''
993 check
"$expected" "$actual"
996 # check that text/plain part is not added to text/html in multipart/related
997 # when it shouldn't be
998 start_test
"text/plain part is not added to text/html in multipart/related when it shouldn't be"
999 cat >"`mhpath new`" <<EOF
1001 Date: Tue, 26 Feb 2013 18:07:20 -0600
1002 Subject: multipart/related, not /alternative
1003 Content-Type: multipart/related;
1004 type="text/html"; boundary="----=_Part_90310_101292502.1"
1006 ------=_Part_90310_101292502.1
1007 Content-Type: text/html; charset="us-ascii"
1008 Content-Transfer-Encoding: 7bit
1011 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1012 <title>HTML Content</title>
1015 This is the real content.
1019 ------=_Part_90310_101292502.1
1020 Content-Type: text/plain; charset="us-ascii"
1021 Content-Transfer-Encoding: 7bit
1023 Your email client does not support HTML messages
1025 ------=_Part_90310_101292502.1--
1028 cp -p "`mhpath last`" "$expected"
1030 if [ $can_reformat_texthtml -eq 1 ]; then
1031 #### lynx inserts multiple blank lines, so squeeze them.
1032 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1033 check
"$expected" "$actual" 'ignore space'
1039 # check that text/plain part is added to text/html in multipart/related
1041 start_test
"text/plain part is added to text/html in multipart/related when it should be"
1042 cat >"$expected" <<EOF
1044 Date: Tue, 26 Feb 2013 18:07:20 -0600
1045 Subject: multipart/related, not /alternative
1046 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1048 ------=_Part_90310_101292502.1
1049 Content-Type: text/plain; charset="us-ascii"
1050 Content-Transfer-Encoding: 7bit
1052 This is the real content.
1054 ------=_Part_90310_101292502.1
1055 Content-Type: text/html; charset="us-ascii"
1056 Content-Transfer-Encoding: 7bit
1059 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1060 <title>HTML Content</title>
1063 This is the real content.
1067 ------=_Part_90310_101292502.1--
1070 cat >"`mhpath new`" <<EOF
1072 Date: Tue, 26 Feb 2013 18:07:20 -0600
1073 Subject: multipart/related, not /alternative
1074 Content-Type: multipart/related;
1075 type="text/html"; boundary="----=_Part_90310_101292502.1"
1077 ------=_Part_90310_101292502.1
1078 Content-Type: text/html; charset="us-ascii"
1079 Content-Transfer-Encoding: 7bit
1082 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1083 <title>HTML Content</title>
1086 This is the real content.
1090 ------=_Part_90310_101292502.1--
1093 if [ $can_reformat_texthtml -eq 1 ]; then
1094 #### lynx inserts multiple blank lines, so squeeze them.
1095 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1096 check
"$expected" "$actual" 'ignore space'
1102 # check handling of rfc822 message type
1103 # also, checks -fixboundary
1104 start_test
"handling of rfc822 message type"
1105 cat >"$expected" <<EOF
1106 From: Test <test@example.com>
1107 To: Some User <user@example.com>
1108 Date: Fri, 29 Sep 2006 00:00:00
1109 Message-Id: @test.nmh
1110 Subject: message with message/rfc822 attachment
1112 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1114 and some garbage before the attachment
1116 ------- =_aaaaaaaaaa0
1117 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1118 Content-Description: 1552
1119 Content-Disposition: attachment; filename="1552"
1121 From: Test <test@example.com>
1122 To: <another_user@example.com>
1123 Date: Thu, 28 Sep 2006 00:00:00
1124 Message-Id: @test.nmh
1125 Subject: message/rfc822 attachment
1127 This is an RFC-822 message.
1129 ------- =_aaaaaaaaaa0--
1131 and some garbage at the end
1134 cat >"`mhpath new`" <<EOF
1135 From: Test <test@example.com>
1136 To: Some User <user@example.com>
1137 Date: Fri, 29 Sep 2006 00:00:00
1138 Message-Id: @test.nmh
1139 Subject: message with message/rfc822 attachment
1141 Content-Type: multipart/mixed; boundary="----- =badboundary"
1143 and some garbage before the attachment
1145 ------- =_aaaaaaaaaa0
1146 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1147 Content-Description: 1552
1148 Content-Disposition: attachment; filename="1552"
1150 From: Test <test@example.com>
1151 To: <another_user@example.com>
1152 Date: Thu, 28 Sep 2006 00:00:00
1153 Message-Id: @test.nmh
1154 Subject: message/rfc822 attachment
1156 This is an RFC-822 message.
1158 ------- =_aaaaaaaaaa0--
1160 and some garbage at the end
1163 run_test
'mhfixmsg last -outfile '"$actual" ''
1164 check
"$expected" "$actual"
1167 # check not stripping of CRs from ASCII text context (default)
1168 start_test
"not stripping of CRs from ASCII text context (default)"
1169 cat >"$expected" <<EOF
1171 From: sender@example.com
1172 To: recipient@example.com
1173 Subject: message with CR's
1174 Date: Mon, 29 Apr 2013 11:51:45 -0400
1176 There are two CR-LF pairs at the end of this sentence.
1180 cat >"`mhpath new`" <<'EOF'
1182 From: sender@example.com
1183 To: recipient@example.com
1184 Subject: message with CR's
1185 Date: Mon, 29 Apr 2013 11:51:45 -0400
1187 There are two CR-LF pairs at the end of this sentence.
1191 run_prog mhfixmsg last
-outfile "$actual"
1192 check
"$expected" "$actual"
1195 # check stripping of CRs from ASCII text context
1196 start_test
"stripping of CRs from ASCII text context"
1197 cat >"$expected" <<EOF
1199 From: sender@example.com
1200 To: recipient@example.com
1201 Subject: message with CR's
1202 Date: Mon, 29 Apr 2013 11:51:45 -0400
1204 There were two CR-LF pairs at the end of this sentence.
1208 cat >"`mhpath new`" <<'EOF'
1210 From: sender@example.com
1211 To: recipient@example.com
1212 Subject: message with CR's
1213 Date: Mon, 29 Apr 2013 11:51:45 -0400
1215 There were two CR-LF pairs at the end of this sentence.
1219 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1220 check
"$expected" "$actual"
1223 # check -replacetextplain
1224 start_test
"-replacetextplain"
1225 prepare_space
>"$expected" <<EOF
1226 To: recipient@example.com
1227 From: sender@example.com
1228 Subject: mhfixmsg replacement of bad text/plain part test
1230 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1233 Content-Type: text/plain; charset="UTF-8"
1234 Content-Transfer-Encoding: 7bit
1236 Yes, the text/plain part really was empty.
1239 Content-Type: text/html; charset="UTF-8"
1240 Content-Disposition: inline
1243 <title>eticket</title>
1246 Yes, the text/plain part really was empty.
1250 ------=_Part_876302--
1253 cat >"`mhpath new`" <<'EOF'
1254 To: recipient@example.com
1255 From: sender@example.com
1256 Subject: mhfixmsg replacement of bad text/plain part test
1258 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1261 Content-Type: text/plain; charset="iso-8859-15"
1262 Content-Transfer-Encoding: 7bit
1263 Content-Disposition: inline
1268 Content-Type: text/html; charset="UTF-8"
1269 Content-Disposition: inline
1272 <title>eticket</title>
1275 Yes, the text/plain part really was empty.
1279 ------=_Part_876302--
1282 if [ $can_reformat_texthtml -eq 1 ]; then
1283 #### lynx inserts multiple blank lines, so squeeze them.
1284 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1285 squeeze_lines
> "$actual"
1286 check
"$expected" "$actual" 'ignore space'
1292 # check -noreplacetextplain
1293 start_test
"-noreplacetextplain"
1294 cat >"$expected" <<EOF
1295 To: recipient@example.com
1296 From: sender@example.com
1297 Subject: mhfixmsg replacement of bad text/plain part test
1299 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1302 Content-Type: text/plain; charset="iso-8859-15"
1303 Content-Transfer-Encoding: 7bit
1304 Content-Disposition: inline
1309 Content-Type: text/html; charset="UTF-8"
1310 Content-Disposition: inline
1313 <title>eticket</title>
1316 Yes, the text/plain part really was empty.
1320 ------=_Part_876302--
1323 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1324 check
"$expected" "$actual"
1327 # check removal of extraneous trailing semicolon from header parameter list
1328 start_test
"removal of extraneous trailing semicolon from header parameter list"
1329 cat >"$expected" <<EOF
1330 To: recipient@example.com
1332 From: sender@example.com
1334 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1336 ------- =_aaaaaaaaaa0
1337 Content-Type: text/plain; charset="us-ascii"
1341 ------- =_aaaaaaaaaa0
1342 Content-Type: text/plain; charset="us-ascii";
1344 Content-Description: check folded headers, with and without trailing semicolon
1345 Content-Disposition: attachment;
1350 ------- =_aaaaaaaaaa0--
1353 cat >"`mhpath new`" <<EOF
1354 To: recipient@example.com
1356 From: sender@example.com
1358 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1360 ------- =_aaaaaaaaaa0
1361 Content-Type: text/plain; charset="us-ascii";
1365 ------- =_aaaaaaaaaa0
1366 Content-Type: text/plain; charset="us-ascii";
1368 Content-Description: check folded headers, with and without trailing semicolon
1369 Content-Disposition: attachment;
1374 ------- =_aaaaaaaaaa0--
1376 run_test
'mhfixmsg last -outfile '"$actual" ''
1377 check
"$expected" "$actual"
1380 if [ $can_reformat_texthtml -eq 1 ]; then
1382 start_test
"rmmproc"
1383 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1386 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1387 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1388 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1390 run_test
'mhfixmsg 16' ''
1391 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1392 "${MH_TEST_DIR}/Mail/inbox/16.original"
1396 start_test
"-normmproc"
1397 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1399 run_test
'mhfixmsg 21 -normmproc'
1400 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1401 "${MH_TEST_DIR}/Mail/inbox/${sbackup}21" 'keep first'
1406 start_test
"-rmmproc"
1407 run_test
'mhfixmsg 21 -rmmproc true'
1408 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1409 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1410 failed
=`expr ${failed:-0} + 1`
1415 start_test
"-fixtype"
1416 cat >"$expected" <<EOF
1417 To: recipient@example.com
1418 From: sender@example.com
1419 Subject: mhfixmsg with incorrect Content-Type
1421 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1423 ------- =_aaaaaaaaaa0
1424 Content-Type: text/plain; name="plaintext.txt"
1428 ------- =_aaaaaaaaaa0--
1431 cat >"`mhpath new`" <<EOF
1432 To: recipient@example.com
1433 From: sender@example.com
1434 Subject: mhfixmsg with incorrect Content-Type
1436 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1438 ------- =_aaaaaaaaaa0
1439 Content-Type: application/octet-stream; name="plaintext.txt"
1443 ------- =_aaaaaaaaaa0--
1446 mhfixmsg
-fixtype application
/octet-stream last
1447 check
"$expected" "`mhpath last`"
1450 # check default -decodetypes
1451 start_test
"default -decodetypes"
1452 cat >$expected <<EOF
1453 To: recipient@example.com
1454 From: sender@example.com
1455 Subject: mhfixmsg decode test 3
1457 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1459 ------- =_aaaaaaaaaa0
1460 Content-Type: text/plain; charset="iso-8859-1"
1461 Content-Disposition: attachment; filename="test1.txt"
1462 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1463 Content-Transfer-Encoding: 7bit
1465 This is the text/plain part.
1467 ------- =_aaaaaaaaaa0
1468 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1469 Content-Disposition: attachment; filename="test2.txt"
1470 Content-Transfer-Encoding: 7bit
1474 This was the text/html part.
1479 ------- =_aaaaaaaaaa0--
1482 cat >"`mhpath new`" <<EOF
1483 To: recipient@example.com
1484 From: sender@example.com
1485 Subject: mhfixmsg decode test 3
1487 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1489 ------- =_aaaaaaaaaa0
1490 Content-Type: text/plain; charset="iso-8859-1"
1491 Content-Disposition: attachment; filename="test1.txt"
1492 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1493 Content-Transfer-Encoding: quoted-printable
1495 This is the text/plain part.
1497 ------- =_aaaaaaaaaa0
1498 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1499 Content-Disposition: attachment; filename="test2.txt"
1500 Content-Transfer-Encoding: base64
1502 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1503 Ym9keT4KPC9odG1sPgo=
1505 ------- =_aaaaaaaaaa0--
1507 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1508 check
"$expected" "$actual"
1511 # check -decodetypes text/plain
1512 start_test
"-decodetypes text/plain"
1513 cat >$expected <<EOF
1514 To: recipient@example.com
1515 From: sender@example.com
1516 Subject: mhfixmsg decode test 4
1518 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1520 ------- =_aaaaaaaaaa0
1521 Content-Type: text/plain; charset="iso-8859-1"
1522 Content-Disposition: attachment; filename="test1.txt"
1523 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1524 Content-Transfer-Encoding: 7bit
1526 This is the text/plain part.
1528 ------- =_aaaaaaaaaa0
1529 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1530 Content-Disposition: attachment; filename="test2.txt"
1531 Content-Transfer-Encoding: base64
1533 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1534 CjwvYm9keT4NCjwvaHRtbD4NCg==
1536 ------- =_aaaaaaaaaa0--
1539 cat >"`mhpath new`" <<EOF
1540 To: recipient@example.com
1541 From: sender@example.com
1542 Subject: mhfixmsg decode test 4
1544 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1546 ------- =_aaaaaaaaaa0
1547 Content-Type: text/plain; charset="iso-8859-1"
1548 Content-Disposition: attachment; filename="test1.txt"
1549 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1550 Content-Transfer-Encoding: quoted-printable
1552 This is the text/plain part.
1554 ------- =_aaaaaaaaaa0
1555 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1556 Content-Disposition: attachment; filename="test2.txt"
1557 Content-Transfer-Encoding: base64
1559 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1560 CjwvYm9keT4NCjwvaHRtbD4NCg==
1562 ------- =_aaaaaaaaaa0--
1564 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1565 check
"$expected" "$actual"
1568 # check -decodetypes attachment/ics
1569 start_test
"-decodetypes attachment/ics"
1570 cat >$expected <<EOF
1571 To: recipient@example.com
1572 From: sender@example.com
1573 Subject: mhfixmsg decode test 5
1575 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1577 ------- =_aaaaaaaaaa0
1578 Content-Type: text/plain; charset="iso-8859-1"
1579 Content-Disposition: attachment; filename="test1.txt"
1580 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1581 Content-Transfer-Encoding: 7bit
1583 This is the text/plain part.
1585 ------- =_aaaaaaaaaa0
1586 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1587 Content-Disposition: attachment; filename="invite.ics"
1588 Content-Transfer-Encoding: 7bit
1594 DTSTAMP:20150101T162400Z
1595 DTSTART:20150105T160000
1596 DTEND:20150105T163000
1597 SUMMARY:4 pm meeting
1601 ------- =_aaaaaaaaaa0--
1604 cat >"`mhpath new`" <<EOF
1605 To: recipient@example.com
1606 From: sender@example.com
1607 Subject: mhfixmsg decode test 5
1609 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1611 ------- =_aaaaaaaaaa0
1612 Content-Type: text/plain; charset="iso-8859-1"
1613 Content-Disposition: attachment; filename="test1.txt"
1614 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1615 Content-Transfer-Encoding: quoted-printable
1620 ------- =_aaaaaaaaaa0
1621 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1622 Content-Disposition: attachment; filename="invite.ics"
1623 Content-Transfer-Encoding: base64
1625 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1626 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1627 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1628 CkVORDpWQ0FMRU5EQVINCg==
1630 ------- =_aaaaaaaaaa0--
1632 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1633 check
"$expected" "$actual"
1636 # check -decodetypes attachment/ics and -nocrlflinebreaks
1637 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1638 cat >$expected <<EOF
1639 To: recipient@example.com
1640 From: sender@example.com
1641 Subject: mhfixmsg decode test 5
1643 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1645 ------- =_aaaaaaaaaa0
1646 Content-Type: text/plain; charset="iso-8859-1"
1647 Content-Disposition: attachment; filename="test1.txt"
1648 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1649 Content-Transfer-Encoding: 7bit
1651 This is the text/plain part.
1653 ------- =_aaaaaaaaaa0
1654 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1655 Content-Disposition: attachment; filename="invite.ics"
1656 Content-Transfer-Encoding: 7bit
1662 DTSTAMP:20150101T162400Z
1663 DTSTART:20150105T160000
1664 DTEND:20150105T163000
1665 SUMMARY:4 pm meeting
1669 ------- =_aaaaaaaaaa0--
1672 cat >"`mhpath new`" <<EOF
1673 To: recipient@example.com
1674 From: sender@example.com
1675 Subject: mhfixmsg decode test 5
1677 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1679 ------- =_aaaaaaaaaa0
1680 Content-Type: text/plain; charset="iso-8859-1"
1681 Content-Disposition: attachment; filename="test1.txt"
1682 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1683 Content-Transfer-Encoding: quoted-printable
1688 ------- =_aaaaaaaaaa0
1689 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1690 Content-Disposition: attachment; filename="invite.ics"
1691 Content-Transfer-Encoding: base64
1693 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1694 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1695 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1696 CkVORDpWQ0FMRU5EQVINCg==
1698 ------- =_aaaaaaaaaa0--
1700 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1701 check
"$expected" "$actual"
1704 # check that input is passed through to output when there's a parse error
1705 # (the charset string is missing its closing quote) with -outfile
1706 start_test
"input is passed through to output when there's a parse error"
1707 cat >"$expected.err" <<EOF
1708 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1710 mhfixmsg: unable to parse message 31
1713 cat >"`mhpath new`" <<EOF
1714 To: recipient@example.com
1715 From: sender@example.com
1716 Subject: mhfixmsg pass through on parse error
1718 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1720 ------- =_aaaaaaaaaa0
1721 Content-Type: text/plain; charset="iso-8859-1
1722 Content-Disposition: attachment; filename="test1.txt"
1723 Content-Transfer-Encoding: quoted-printable
1728 ------- =_aaaaaaaaaa0--
1731 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1733 #### Expected output is identical to the input message.
1734 check
"`mhpath last`" "$actual" 'keep first'
1735 check
"$expected.err" "$actual.err"
1738 # check that input is passed through to output when there's a parse error
1739 # (the charset string is missing its closing quote) with -outfile, and
1740 # input from stdin. Don't check err output, because it contains the name
1741 # of a tmp file. It's similar to that of the previous check.
1742 start_test
"input is passed through to output when there's a parse error"
1744 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1746 #### Expected output is identical to the input message.
1747 check
"`mhpath last`" "$actual" 'keep first'
1750 start_test
"pass through message with relative folder path with parse error"
1751 #### Factor out leading portion of current folder path and make it relative.
1754 run_prog mhfixmsg
+.
/`mhpath | sed "s%^$pwd/%%"` last
-out - >"$actual" 2>/dev
/null
1756 folder
-f +inbox
>/dev
/null
1757 #### Expected output is identical to the input message.
1758 check
"`mhpath last`" "$actual"
1761 start_test
"fix RFC 2047 encoded header parameters"
1762 #### Also, add C-T-E:8bit to the message headers.
1763 cat >"$expected" <<EOF
1764 To: recipient@example.com
1765 From: sender@example.com
1766 Date: Wed, 28 Sep 2016 11:24:28 -0400
1767 Subject: invalid header parameter encoding
1769 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1770 Content-Transfer-Encoding: 8bit
1772 --001a114dd3e8fe9c56053d92f414
1773 Content-Type: text/plain; charset=UTF-8
1777 --001a114dd3e8fe9c56053d92f414
1778 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1779 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1780 Content-Transfer-Encoding: 8bit
1782 This is the first text/plain part, in a subpart. The file name
1785 --001a114dd3e8fe9c56053d92f414--
1788 cat >"`mhpath new`" <<EOF
1789 To: recipient@example.com
1790 From: sender@example.com
1791 Date: Wed, 28 Sep 2016 11:24:28 -0400
1792 Subject: invalid header parameter encoding
1794 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1796 --001a114dd3e8fe9c56053d92f414
1797 Content-Type: text/plain; charset=UTF-8
1801 --001a114dd3e8fe9c56053d92f414
1802 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1803 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1804 Content-Transfer-Encoding: 8bit
1806 This is the first text/plain part, in a subpart. The file name
1809 --001a114dd3e8fe9c56053d92f414--
1811 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1812 check
"$expected" "$actual"
1815 start_test
"-nodecodeheaderfieldbodies"
1816 cat >"`mhpath new`" <<EOF
1817 To: recipient@example.com
1818 From: sender@example.com
1819 Date: Wed, 28 Sep 2016 11:24:28 -0400
1820 Subject: =?utf-8?B?dGhpcyBTdWJqZWN0IHdhcyBVVEYtOCBlbmNvZGVk?=
1822 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1823 Content-Transfer-Encoding: 8bit
1825 --001a114dd3e8fe9c56053d92f414
1826 Content-Type: text/plain; charset=UTF-8
1830 --001a114dd3e8fe9c56053d92f414
1831 Content-Type: text/plain; charset=UTF-8; name="test.txt"
1832 Content-Disposition: attachment; filename="test.txt"
1833 Content-Transfer-Encoding: 8bit
1835 This is the first text/plain part, in a subpart. The file name
1838 --001a114dd3e8fe9c56053d92f414--
1840 run_prog mhfixmsg
-file - -outfile - -decodeheaderfieldbodies utf-8 \
1841 -nodecodeheaderfieldbodies <`mhpath last` >"$actual" 2>/dev
/null
1842 check
`mhpath last` "$actual" 'keep first'
1845 start_test
"test decoding of UTF-8 header value"
1846 cat >"$expected" <<EOF
1847 To: recipient@example.com
1848 From: sender@example.com
1849 Date: Wed, 28 Sep 2016 11:24:28 -0400
1850 Subject: this Subject was UTF-8 encoded
1852 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1853 Content-Transfer-Encoding: 8bit
1855 --001a114dd3e8fe9c56053d92f414
1856 Content-Type: text/plain; charset=UTF-8
1860 --001a114dd3e8fe9c56053d92f414
1861 Content-Type: text/plain; charset=UTF-8; name="test.txt"
1862 Content-Disposition: attachment; filename="test.txt"
1863 Content-Transfer-Encoding: 8bit
1865 This is the first text/plain part, in a subpart. The file name
1868 --001a114dd3e8fe9c56053d92f414--
1871 run_prog mhfixmsg
-file - -outfile - -decodeheaderfieldbodies utf-8 \
1872 <`mhpath last` >"$actual" 2>/dev
/null
1873 check
"$expected" "$actual"
1876 start_test
"-checkbase64 with base64 code that ends with == plus footer"
1877 cat >"`mhpath new`" <<EOF
1878 From: Test <test@example.com>
1879 Subject: base64 code that ends with ==
1881 Content-Type: text/plain
1882 Content-Transfer-Encoding: base64
1884 VGhpcyBpcyBzb21lIHRleHQuCg==
1887 Wait, this shouldn't be here.
1890 cat >"$expected" <<EOF
1891 From: Test <test@example.com>
1892 Subject: base64 code that ends with ==
1894 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
1896 ------=_nmh-multipart
1897 Content-Type: text/plain
1898 Content-Transfer-Encoding: 7bit
1902 ------=_nmh-multipart
1903 Content-Type: text/plain
1904 Content-Transfer-Encoding: 7bit
1907 Wait, this shouldn't be here.
1909 ------=_nmh-multipart--
1911 run_prog mhfixmsg last
-outfile "$actual"
1912 check
"$expected" "$actual"
1915 start_test
"-checkbase64 with -nodecodetext"
1916 cat >"`mhpath new`" <<EOF
1917 From: Test <test@example.com>
1918 Subject: base64 code that ends with ==
1920 Content-Type: text/plain
1921 Content-Transfer-Encoding: base64
1923 VGhpcyBpcyBzb21lIHRleHQuCg==
1926 Wait, this shouldn't be here.
1929 cat >"$expected" <<EOF
1930 From: Test <test@example.com>
1931 Subject: base64 code that ends with ==
1933 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
1935 ------=_nmh-multipart
1936 Content-Type: text/plain
1937 Content-Transfer-Encoding: base64
1939 VGhpcyBpcyBzb21lIHRleHQuCg==
1941 ------=_nmh-multipart
1942 Content-Type: text/plain
1943 Content-Transfer-Encoding: 7bit
1946 Wait, this shouldn't be here.
1948 ------=_nmh-multipart--
1950 run_prog mhfixmsg
-nodecodetext last
-outfile "$actual"
1951 check
"$expected" "$actual"
1954 start_test
"-checkbase64 with base64 code that ends with = plus footer"
1955 cat >"`mhpath new`" <<EOF
1956 From: Test <test@example.com>
1957 Subject: base64 code that ends with =
1959 Content-Type: text/plain
1960 Content-Transfer-Encoding: base64
1962 VGhpcyBpcyBwbGFpbiB0ZXh0Lgo=
1965 Wait, this shouldn't be here.
1968 cat >"$expected" <<EOF
1969 From: Test <test@example.com>
1970 Subject: base64 code that ends with =
1972 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
1974 ------=_nmh-multipart
1975 Content-Type: text/plain
1976 Content-Transfer-Encoding: 7bit
1980 ------=_nmh-multipart
1981 Content-Type: text/plain
1982 Content-Transfer-Encoding: 7bit
1985 Wait, this shouldn't be here.
1987 ------=_nmh-multipart--
1989 run_prog mhfixmsg last
-outfile "$actual"
1990 check
"$expected" "$actual"
1993 start_test
"-checkbase64 with base64 code that ends without = plus footer"
1994 cat >"`mhpath new`" <<EOF
1995 From: Test <test@example.com>
1996 Subject: base64 code that ends without =
1998 Content-Type: text/plain
1999 Content-Transfer-Encoding: base64
2001 VGhpcyBpcyBzb21lIHRleHQK
2004 Wait, this shouldn't be here.
2007 cat >"$expected" <<EOF
2008 From: Test <test@example.com>
2009 Subject: base64 code that ends without =
2011 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
2013 ------=_nmh-multipart
2014 Content-Type: text/plain
2015 Content-Transfer-Encoding: 7bit
2019 ------=_nmh-multipart
2020 Content-Type: text/plain
2021 Content-Transfer-Encoding: 7bit
2024 Wait, this shouldn't be here.
2026 ------=_nmh-multipart--
2028 run_prog mhfixmsg last
-outfile "$actual"
2029 check
"$expected" "$actual"
2032 start_test
"-checkbase64 with base64 code that contains single invalid character"
2033 cat >"`mhpath new`" <<EOF
2034 From: Test <test@example.com>
2035 Subject: base64 code that ends without =
2037 Content-Type: text/plain
2038 Content-Transfer-Encoding: base64
2040 VGhpcyBpcyBzb21lIHRleHQK
2043 Wait, this shouldn't be here.
2046 cat >"$expected" <<EOF
2047 From: Test <test@example.com>
2048 Subject: base64 code that ends without =
2050 Content-Type: text/plain
2051 Content-Transfer-Encoding: base64
2053 VGhpcyBpcyBzb21lIHRleHQK
2056 Wait, this shouldn't be here.
2059 cat >"$expected_err" <<EOF
2060 mhfixmsg: invalid base64 byte 0x2d: -X-
2061 Wait, this shouldn't be here.
2065 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual_err" || true
2066 check
"$expected" "$actual"
2067 check
"$expected_err" "$actual_err"
2070 start_test
"-checkbase64 with base64 code in MIME part"
2071 cat >"`mhpath new`" <<EOF
2072 From: Test <test@example.com>
2073 Subject: MIME part with base64 encoded text and unencoded footer
2075 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
2077 ------=_nmh-multipart
2078 Content-Type: text/plain
2079 Content-Transfer-Encoding: base64
2081 VGhpcyBpcyBzb21lIHRleHQK
2084 Wait, this shouldn't be here.
2086 ------=_nmh-multipart
2087 Content-Type: text/plain
2088 Content-Transfer-Encoding: 7bit
2090 This is a second text/plain part.
2092 ------=_nmh-multipart--
2095 cat >"$expected" <<EOF
2096 From: Test <test@example.com>
2097 Subject: MIME part with base64 encoded text and unencoded footer
2099 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
2101 ------=_nmh-multipart
2102 Content-Type: multipart/mixed; boundary="----=_nmh-multipart1"
2104 ------=_nmh-multipart1
2105 Content-Type: text/plain
2106 Content-Transfer-Encoding: 7bit
2110 ------=_nmh-multipart1
2111 Content-Type: text/plain
2112 Content-Transfer-Encoding: 7bit
2115 Wait, this shouldn't be here.
2117 ------=_nmh-multipart1--
2119 ------=_nmh-multipart
2120 Content-Type: text/plain
2121 Content-Transfer-Encoding: 7bit
2123 This is a second text/plain part.
2125 ------=_nmh-multipart--
2127 run_prog mhfixmsg last
-outfile "$actual"
2128 check
"$expected" "$actual"
2131 start_test
"-checkbase64 with 8-bit encoded base64 code"
2132 cat >"`mhpath new`" <<EOF
2133 From: Test <test@example.com>
2134 Subject: 8-bit encoded base64 code
2136 Content-Type: text/plain
2137 Content-Transfer-Encoding: base64
2139 U2VlIFJGQyAyMDQ1IMKnNi44Lg==
2142 Wait, this shouldn't be here.
2144 cat >"$expected" <<EOF
2145 From: Test <test@example.com>
2146 Subject: 8-bit encoded base64 code
2148 Content-Type: multipart/mixed; boundary="----=_nmh-multipart"
2149 Content-Transfer-Encoding: 8bit
2151 ------=_nmh-multipart
2152 Content-Type: text/plain
2153 Content-Transfer-Encoding: 8bit
2157 ------=_nmh-multipart
2158 Content-Type: text/plain
2159 Content-Transfer-Encoding: 7bit
2162 Wait, this shouldn't be here.
2164 ------=_nmh-multipart--
2167 run_prog mhfixmsg last
-outfile "$actual"
2168 check
"$expected" "$actual"
2171 # make sure there are no tmp files left over
2172 find "$MH_TEST_DIR/Mail" -name '*mhfix*' -print \
2174 cat >"$expected" <<EOF
2177 check
"$expected" "$actual"