2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"${MH_OBJ_DIR}/test/common.sh"
19 #### Make sure that html-to-text conversion is what we expect.
20 require_locale en_US.UTF
-8 en_US.UTF8 en_US.utf
-8 en_US.utf8
22 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
23 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
24 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
25 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
27 mhn_defaults
="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
29 if grep mhfixmsg
-format-text/html
"${mhn_defaults}" \
31 can_reformat_texthtml
=1
32 if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
34 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
35 #### support testing with non-writeable $HOME, and to not leave
36 #### relics from this test if it is writeable but doesn't already
37 #### have a .w3m, and to not depend on whatever is in that if it
38 #### does already exist, overwrite $HOME if using w3m.
39 HOME
="$MHTMPDIR"; export HOME
42 echo "$0: skipping -reformat check because no text browser was found"
43 can_reformat_texthtml
=0
49 cat >"$expected" <<EOF
50 Usage: mhfixmsg [+folder] [msgs] [switches]
52 -decodetext 8bit|7bit|binary
72 #### Skip nmh intro text.
73 run_prog mhfixmsg
-help | sed '/^$/,$d' >"$actual" 2>&1
74 check
"$expected" "$actual"
79 case `mhfixmsg -version` in
81 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
82 failed
=`expr ${failed:-0} + 1`;;
86 # check that non-MIME messages aren't modified
88 start_test
"that non-MIME messages aren't modified, and -outfile"
89 run_test
'mhfixmsg first -outfile '"$actual" ''
90 check
"`mhpath first`" "$actual" 'keep first'
93 # check that non-MIME messages with no bodies aren't modified
95 start_test
"that non-MIME messages with no bodies aren't modified, and -outfile"
96 cat >`mhpath new` <<EOF
97 From: Test <test@example.com>
98 To: Some User <user@example.com>
99 Date: Fri, 29 Sep 2006 00:00:00
100 Message-Id: @test.nmh
101 Subject: message with no body
104 run_test
'mhfixmsg last -outfile '"$actual" ''
105 check
"`mhpath last`" "$actual"
109 start_test
"-nofixcte"
110 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
113 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
114 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
116 Content-Type: MULTIPART/MIXED;
117 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
118 Content-Transfer-Encoding: QUOTED-PRINTABLE
120 This message is in MIME format. The first part should be readable
122 while the remaining parts are likely unreadable without MIME-aware
125 ------=_NextPart_000_0000_00000000.00000000
126 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
127 Content-Transfer-Encoding: 8BIT
129 Some text in swedish.
131 Varf=C3=B6r inte anv=C3=A4nda...
133 ------=_NextPart_000_0000_00000000.00000000--
135 And some text after the last part.
138 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
140 run_test
'mhfixmsg last -nofixcte' ''
141 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
144 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
146 start_test
"-fixcte (enabled by default): fixup of erroneous C-T-E in multipart, and -verbose"
147 cat >"$expected" <<EOF
150 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
151 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
153 Content-Type: MULTIPART/MIXED;
154 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
155 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
156 Content-Transfer-Encoding: 8bit
158 This message is in MIME format. The first part should be readable
160 while the remaining parts are likely unreadable without MIME-aware
163 ------=_NextPart_000_0000_00000000.00000000
164 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
165 Content-Transfer-Encoding: 8BIT
167 Some text in swedish.
169 Varf=C3=B6r inte anv=C3=A4nda...
171 ------=_NextPart_000_0000_00000000.00000000--
173 And some text after the last part.
176 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
177 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
178 QUOTED-PRINTABLE with 8 bit"
179 check
"$expected" "$actual" 'keep first'
182 # check with no options: checks backup
183 start_test
"with no options: checks backup"
184 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
185 folder last
>/dev
/null
186 run_test
'mhfixmsg' ''
187 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
188 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
189 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
192 # check backup with -file
193 start_test
"backup with -file"
194 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
195 folder last
>/dev
/null
196 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
197 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
198 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
201 # check -reformat (enabled by default): addition of text/plain part
202 # to solitary text/html part
203 start_test
"-reformat (enabled by default): addition of text/plain part"
204 prepare_space
>"$expected" <<EOF
206 From: sender@example.com
207 To: bonquiqui@example.com
209 Date: Sat, 26 Jan 2013 17:37:53 -0500
210 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
212 ------=_nmh-multipart
213 Content-Type: text/plain; charset="Windows-1252"
214 Content-Transfer-Encoding: 7bit
216 Need to go! Need ... to ... go!
218 ------=_nmh-multipart
219 Content-Type: text/html; charset="Windows-1252"
220 Content-Transfer-Encoding: 7bit
224 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
225 <meta name="Generator" content="Microsoft Exchange Server">
226 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
230 <div>Need to go! Need ... to ... go!</div>
234 ------=_nmh-multipart--
237 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
239 From: sender@example.com
240 To: bonquiqui@example.com
242 Date: Sat, 26 Jan 2013 17:37:53 -0500
243 Content-Type: text/html; charset="Windows-1252"
244 Content-Transfer-Encoding: quoted-printable
248 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
250 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
251 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
252 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
256 <div>Need to go! Need ... to ... go!</div>
261 if [ $can_reformat_texthtml -eq 1 ]; then
262 printf '%s\n' "mhfixmsg: 12, insert text/plain part
263 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
266 #### lynx inserts multiple blank lines, so squeeze them.
267 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
268 squeeze_lines
>"$actual"
269 check
"$expected" "$actual" 'ignore space'
270 check
"$expected.err" "$actual.err"
276 # check implicit -file with absolute pathname
277 start_test
"implicit -file with absolute pathname"
278 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
281 # check handling of boundary string that appears in message body
282 start_test
"handling of boundary string that appears in message body"
283 prepare_space
>"$expected" <<EOF
285 From: sender@example.com
286 To: bonquiqui@example.com
288 Date: Sat, 26 Jan 2013 17:37:53 -0500
289 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
291 ------=_nmh-multipart-3
292 Content-Type: text/plain; charset="Windows-1252"
293 Content-Transfer-Encoding: 7bit
295 ------=_nmh-multipart
296 ------=_nmh-multipart-1
297 ------=_nmh-multipart-2
299 ------=_nmh-multipart-3
300 Content-Type: text/html; charset="Windows-1252"
301 Content-Transfer-Encoding: 7bit
305 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
306 <meta name="Generator" content="Microsoft Exchange Server">
307 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
310 ------=_nmh-multipart<br>
311 ------=_nmh-multipart-1<br>
312 ------=_nmh-multipart-2<br>
316 ------=_nmh-multipart-3--
319 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
321 From: sender@example.com
322 To: bonquiqui@example.com
324 Date: Sat, 26 Jan 2013 17:37:53 -0500
325 Content-Type: text/html; charset="Windows-1252"
326 Content-Transfer-Encoding: quoted-printable
330 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
332 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
333 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
334 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
337 ------=3D_nmh-multipart<br>
338 ------=3D_nmh-multipart-1<br>
339 ------=3D_nmh-multipart-2<br>
344 if [ $can_reformat_texthtml -eq 1 ]; then
345 printf '%s\n' "mhfixmsg: 12, insert text/plain part
346 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
349 #### lynx inserts multiple blank lines, so squeeze them.
350 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
351 squeeze_lines
>"$actual"
352 check
"$expected" "$actual" 'ignore space'
353 check
"$expected.err" "$actual.err"
360 start_test
"-nodecode"
361 prepare_space
>"$expected" <<EOF
363 From: sender@example.com
364 To: bonquiqui@example.com
366 Date: Sat, 26 Jan 2013 17:37:53 -0500
367 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
369 ------=_nmh-multipart
370 Content-Type: text/plain; charset="Windows-1252"
371 Content-Transfer-Encoding: 7bit
373 Need to go! Need ... to ... go!
375 ------=_nmh-multipart
376 Content-Type: text/html; charset="Windows-1252"
377 Content-Transfer-Encoding: quoted-printable
381 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
383 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
384 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
385 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
389 <div>Need to go! Need ... to ... go!</div>
393 ------=_nmh-multipart--
396 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
398 From: sender@example.com
399 To: bonquiqui@example.com
401 Date: Sat, 26 Jan 2013 17:37:53 -0500
402 Content-Type: text/html; charset="Windows-1252"
403 Content-Transfer-Encoding: quoted-printable
407 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
409 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
410 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
411 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
415 <div>Need to go! Need ... to ... go!</div>
420 if [ $can_reformat_texthtml -eq 1 ]; then
421 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
423 #### lynx inserts multiple blank lines, so squeeze them.
424 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
425 squeeze_lines
>"$actual"
426 check
"$expected" "$actual" 'ignore space'
427 check
"$expected.err" "$actual.err"
433 # check -decodetext (enabled by default)
434 start_test
"-decodetext (enabled by default)"
435 cat >"$expected" <<EOF
436 To: recipient@example.com
437 From: sender@example.com
438 Subject: mhfixmsg decode test 1
440 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
442 ------- =_aaaaaaaaaa0
443 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
444 Content-Disposition: attachment; filename="test4.txt"
445 Content-Transfer-Encoding: 7bit
447 This is a text/plain part.
449 ------- =_aaaaaaaaaa0--
452 cat >`mhpath new` <<EOF
453 To: recipient@example.com
454 From: sender@example.com
455 Subject: mhfixmsg decode test 1
457 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
459 ------- =_aaaaaaaaaa0
460 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
461 Content-Disposition: attachment; filename="test4.txt"
462 Content-Transfer-Encoding: base64
464 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
466 ------- =_aaaaaaaaaa0--
469 run_prog mhfixmsg last
-outfile "$actual"
470 check
"$expected" "$actual"
473 # check -decodetext with more complicated content structure
474 start_test
"-decodetext with more complicated content structure"
476 To: recipient@example.com
477 From: sender@example.com
478 Subject: mhfixmsg decode test 2
480 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
482 This is additional content before the first subpart of the multipart.
484 ------- =_aaaaaaaaaa0
485 Content-Type: multipart/related;
486 type="text/plain"; boundary="subpart__1.1"
489 Content-Type: text/plain; charset="iso-8859-1"
490 Content-Disposition: attachment; filename="test1.txt"
492 This is the first text/plain part, in a subpart.
496 This is additional content after the last subpart of the multipart.
498 ------- =_aaaaaaaaaa0
499 Content-Type: text/plain; charset="iso-8859-1"
500 Content-Disposition: attachment; filename="test2.txt"
501 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
502 Content-Transfer-Encoding: 7bit
504 This is the second text/plain part.
506 ------- =_aaaaaaaaaa0
507 Content-Type: text/plain; charset="iso-8859-1"
508 Content-Disposition: attachment; filename="test3.txt"
510 This is the third text/plain part.
512 ------- =_aaaaaaaaaa0
513 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
514 Content-Disposition: attachment; filename="test4.txt"
515 Content-Transfer-Encoding: 7bit
517 This is the fourth text/plain part.
519 ------- =_aaaaaaaaaa0--
521 This is additional content after the last subpart of the multipart.
524 cat >`mhpath new` <<EOF
525 To: recipient@example.com
526 From: sender@example.com
527 Subject: mhfixmsg decode test 2
529 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
531 This is additional content before the first subpart of the multipart.
533 ------- =_aaaaaaaaaa0
534 Content-Type: multipart/related;
535 type="text/plain"; boundary="subpart__1.1"
538 Content-Type: text/plain; charset="iso-8859-1"
539 Content-Disposition: attachment; filename="test1.txt"
541 This is the first text/plain part, in a subpart.
545 This is additional content after the last subpart of the multipart.
547 ------- =_aaaaaaaaaa0
548 Content-Type: text/plain; charset="iso-8859-1"
549 Content-Disposition: attachment; filename="test2.txt"
550 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
551 Content-Transfer-Encoding: quoted-printable
553 This is the second text/plain part.
555 ------- =_aaaaaaaaaa0
556 Content-Type: text/plain; charset="iso-8859-1"
557 Content-Disposition: attachment; filename="test3.txt"
559 This is the third text/plain part.
561 ------- =_aaaaaaaaaa0
562 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
563 Content-Disposition: attachment; filename="test4.txt"
564 Content-Transfer-Encoding: base64
566 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
568 ------- =_aaaaaaaaaa0--
570 This is additional content after the last subpart of the multipart.
572 run_prog mhfixmsg last
-outfile "$actual"
573 check
"$expected" "$actual"
576 # check attempted (default, 8 bit) -decodetext of binary text
577 #### Generated the encoded text below with:
578 #### $ printf '\275\262=\274\000\n' | base64
579 start_test
"attempted (default, 8 bit) -decodetext of binary text"
580 cat >`mhpath new` <<EOF
581 To: recipient@example.com
582 From: sender@example.com
583 Subject: mhfixmsg binary decode test
585 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
587 ------- =_aaaaaaaaaa0
588 Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
589 Content-Transfer-Encoding: base64
593 ------- =_aaaaaaaaaa0--
596 cp -p `mhpath last` "$expected"
597 run_prog mhfixmsg last
598 check
`mhpath last` "$expected" 'keep first'
601 # check for successful decode of a different part with attempted -decodetext
602 # of binary (>998 characters) text
603 start_test
"for successful decode of a different part with attempted -decodetext"
605 To: recipient@example.com
606 From: sender@example.com
607 Subject: mhfixmsg successful decode of text/plain with failed binary decode
609 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
611 ------- =_aaaaaaaaaa0
612 Content-Type: text/plain; charset="iso-8859-1"
613 Content-Transfer-Encoding: 7bit
615 This is a text plain part
617 ------- =_aaaaaaaaaa0
618 Content-Type: text/html; charset="ascii"
619 Content-Transfer-Encoding: base64
620 Content-Disposition: inline
622 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
623 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
624 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
625 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
626 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
627 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
628 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
629 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
630 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
631 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
632 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
633 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
634 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
635 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
636 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
637 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
638 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
639 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
640 ICA8L2JvZHk+PC9odG1sPg==
642 ------- =_aaaaaaaaaa0--
645 cat >`mhpath new` <<EOF
646 To: recipient@example.com
647 From: sender@example.com
648 Subject: mhfixmsg successful decode of text/plain with failed binary decode
650 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
652 ------- =_aaaaaaaaaa0
653 Content-Type: text/plain; charset="iso-8859-1"
654 Content-Transfer-Encoding: base64
656 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
658 ------- =_aaaaaaaaaa0
659 Content-Type: text/html; charset="ascii"
660 Content-Transfer-Encoding: base64
661 Content-Disposition: inline
663 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
664 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
665 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
666 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
667 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
668 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
669 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
670 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
671 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
672 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
673 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
674 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
675 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
676 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
677 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
678 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
679 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
680 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
681 ICA8L2JvZHk+PC9odG1sPg==
683 ------- =_aaaaaaaaaa0--
686 run_prog mhfixmsg
-noreformat last
687 check
`mhpath last` "$expected" 'keep first'
690 # check for successful decode of a different part with -decodetext of binary
691 # (>998 characters) text
692 start_test
"for successful decode of a different part with -decodetext of binary"
694 To: recipient@example.com
695 From: sender@example.com
696 Subject: mhfixmsg successful decode of text/plain with failed binary decode
698 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
699 Content-Transfer-Encoding: binary
701 ------- =_aaaaaaaaaa0
702 Content-Type: text/plain; charset="iso-8859-1"
703 Content-Transfer-Encoding: 7bit
705 This is a text plain part
707 ------- =_aaaaaaaaaa0
708 Content-Type: text/html; charset="ascii"
709 Content-Transfer-Encoding: binary
710 Content-Disposition: inline
712 <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>
714 ------- =_aaaaaaaaaa0--
717 run_prog mhfixmsg
-noreformat -decodetext binary last
718 check
`mhpath last` "$expected"
721 # check -decodetext of binary (containing ASCII NUL) text
722 start_test
"-decodetext of binary (containing ASCII NUL) text"
723 printf "%s\275\262=\274\000%s" "To: recipient@example.com
724 From: sender@example.com
725 Subject: mhfixmsg binary decode test
727 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
728 Content-Transfer-Encoding: binary
730 ------- =_aaaaaaaaaa0
731 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
732 Content-Transfer-Encoding: binary
736 ------- =_aaaaaaaaaa0--
738 mhfixmsg last
-decodetext binary
-outfile "$actual"
739 check
"$expected" "$actual"
742 # check that -reformat succeeds when decode of binary text fails
743 start_test
"that -reformat succeeds when decode of binary text fails"
744 prepare_space
>"$expected" <<'EOF'
746 Date: Thu, 11 Apr 2013 02:47:08 -0700
748 From: <sender@example.com>
749 Subject: body requires binary encoding
750 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
752 ------=_nmh-multipart
753 Content-Type: text/plain; charset="ISO-8859-1"
754 Content-Transfer-Encoding: 7bit
759 Vehicle License Fee $1.84
762 ------=_nmh-multipart
763 Content-Type: text/html; charset="ISO-8859-1"
764 Content-Transfer-Encoding: quoted-printable
769 cat >`mhpath new` <<'EOF'
771 Content-Type: text/html; charset="ISO-8859-1"
772 Content-Transfer-Encoding: quoted-printable
773 Date: Thu, 11 Apr 2013 02:47:08 -0700
775 From: <sender@example.com>
776 Subject: body requires binary encoding
779 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
780 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
781 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
782 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
783 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
784 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
785 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
786 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
787 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
788 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
789 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
790 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
791 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
792 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
793 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
794 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
795 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
796 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
797 #333333" size=3D"2">$6.00</font></td></tr>
803 if [ $can_reformat_texthtml -eq 1 ]; then
804 #### lynx inserts multiple blank lines, so squeeze them.
805 #### Truncate to avoid comparing the html portion because it can
806 #### get reformatted.
807 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
808 check
"$expected" "$actual" 'ignore space'
810 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
816 # Also checks preservation of attributes after one (charset) that is
818 start_test
"-textcharset"
819 cat >"$expected" <<EOF
820 To: recipient@example.com
821 From: sender@example.com
822 Subject: mhfixmsg textcharset test
824 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
825 Content-Transfer-Encoding: 8bit
827 ------- =_aaaaaaaaaa0
828 Content-Type: text/plain; charset="utf-8"; name="square.txt"
829 Content-Disposition: attachment; filename="square.txt"
830 Content-Transfer-Encoding: 8bit
834 ------- =_aaaaaaaaaa0--
837 #### Generated the encoded text below with:
838 #### $ printf '\275\262=\274\n' | base64
839 cat >`mhpath new` <<EOF
840 To: recipient@example.com
841 From: sender@example.com
842 Subject: mhfixmsg textcharset test
844 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
846 ------- =_aaaaaaaaaa0
847 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
848 Content-Disposition: attachment; filename="square.txt"
849 Content-Transfer-Encoding: base64
853 ------- =_aaaaaaaaaa0--
856 if test "$ICONV_ENABLED" -eq 1; then
857 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
858 check
"$expected" "$actual"
860 echo "$0: skipping -textcharset check because nmh was built without iconv"
865 # check -nofixboundary
866 start_test
"-nofixboundary"
867 cat >"$expected" <<EOF
870 cat >`mhpath new` <<EOF
871 Date: Fri, 13 May 2011 08:21:12 -0500
872 Content-Type: multipart/alternative;
873 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
874 Content-Transfer-Encoding: 8bit
876 From: <sender@example.com>
877 To: <recipient@example.com>
878 Subject: mhfixmsg bad boundary test
880 This is a multi-part message in MIME format.
882 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
883 Content-Type: text/plain
885 The boundaries of this part don't match the header boundary.
887 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
890 cp -p `mhpath last` `mhpath new`
892 run_test
'mhfixmsg last -nofixboundary' ''
893 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
896 # check that message is not output when fed through stdin
897 start_test
"that message is not output when fed through stdin"
898 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
899 check
"$expected" "$actual"
900 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
901 "$actual.err" >/dev
/null
; then
904 echo "$0: test failed, output is in $actual.err."
905 failed
=`expr ${failed:-0} + 1`
909 # check fixup of erroneous boundary in multipart (-fixboundary,
910 # enabled by default)
912 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
913 cat >"$expected" <<EOF
914 Date: Fri, 13 May 2011 08:21:12 -0500
915 Content-Type: multipart/alternative;
916 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
917 Content-Transfer-Encoding: 8bit
919 From: <sender@example.com>
920 To: <recipient@example.com>
921 Subject: mhfixmsg bad boundary test
923 This is a multi-part message in MIME format.
925 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
926 Content-Type: text/plain
928 The boundaries of this part don't match the header boundary.
930 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
933 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
934 "mhfixmsg: 18, fix multipart boundary"
935 check
"$expected" "$actual"
938 # check that message is not modified when -fixboundary fails
939 start_test
"that message is not modified when -fixboundary fails"
940 cat >`mhpath new` <<EOF
941 Date: Fri, 13 May 2011 08:21:12 -0500
942 Content-Type: multipart/alternative;
943 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
944 Content-Transfer-Encoding: 8bit
946 From: <sender@example.com>
947 To: <recipient@example.com>
948 Subject: mhfixmsg bad boundary test
950 This is a multi-part message in MIME format.
952 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
953 Content-Type: text/plain
955 The boundary below doesn't match the header boundary.
958 NextPart_000_1781A1A_01CC1147.81EBA8D4--
961 cp -p `mhpath last` "$expected"
962 run_test
"mhfixmsg last -outfile $actual" ''
963 check
"$expected" "$actual"
966 # check that text/plain part is not added to text/html in multipart/related
967 # when it shouldn't be
968 start_test
"that text/plain part is not added to text/html in multipart/related when it shouldn't be"
969 cat >`mhpath new` <<EOF
971 Date: Tue, 26 Feb 2013 18:07:20 -0600
972 Subject: multipart/related, not /alternative
973 Content-Type: multipart/related;
974 type="text/html"; boundary="----=_Part_90310_101292502.1"
976 ------=_Part_90310_101292502.1
977 Content-Type: text/html; charset="us-ascii"
978 Content-Transfer-Encoding: 7bit
981 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
982 <title>HTML Content</title>
985 This is the real content.
989 ------=_Part_90310_101292502.1
990 Content-Type: text/plain; charset="us-ascii"
991 Content-Transfer-Encoding: 7bit
993 Your email client does not support HTML messages
995 ------=_Part_90310_101292502.1--
998 cp -p `mhpath last` "$expected"
1000 if [ $can_reformat_texthtml -eq 1 ]; then
1001 #### lynx inserts multiple blank lines, so squeeze them.
1002 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1003 check
"$expected" "$actual" 'ignore space'
1009 # check that text/plain part is added to text/html in multipart/related
1011 start_test
"that text/plain part is added to text/html in multipart/related when it should be"
1012 cat >"$expected" <<EOF
1014 Date: Tue, 26 Feb 2013 18:07:20 -0600
1015 Subject: multipart/related, not /alternative
1016 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1018 ------=_Part_90310_101292502.1
1019 Content-Type: text/plain; charset="us-ascii"
1020 Content-Transfer-Encoding: 7bit
1022 This is the real content.
1024 ------=_Part_90310_101292502.1
1025 Content-Type: text/html; charset="us-ascii"
1026 Content-Transfer-Encoding: 7bit
1029 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1030 <title>HTML Content</title>
1033 This is the real content.
1037 ------=_Part_90310_101292502.1--
1040 cat >`mhpath new` <<EOF
1042 Date: Tue, 26 Feb 2013 18:07:20 -0600
1043 Subject: multipart/related, not /alternative
1044 Content-Type: multipart/related;
1045 type="text/html"; boundary="----=_Part_90310_101292502.1"
1047 ------=_Part_90310_101292502.1
1048 Content-Type: text/html; charset="us-ascii"
1049 Content-Transfer-Encoding: 7bit
1052 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1053 <title>HTML Content</title>
1056 This is the real content.
1060 ------=_Part_90310_101292502.1--
1063 if [ $can_reformat_texthtml -eq 1 ]; then
1064 #### lynx inserts multiple blank lines, so squeeze them.
1065 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1066 check
"$expected" "$actual" 'ignore space'
1072 # check handling of rfc822 message type
1073 start_test
"handling of rfc822 message type"
1074 cat >"$expected" <<EOF
1075 From: Test <test@example.com>
1076 To: Some User <user@example.com>
1077 Date: Fri, 29 Sep 2006 00:00:00
1078 Message-Id: @test.nmh
1079 Subject: message with message/rfc822 attachment
1081 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1083 and some garbage before the attachment
1085 ------- =_aaaaaaaaaa0
1086 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1087 Content-Description: 1552
1088 Content-Disposition: attachment; filename="1552"
1090 From: Test <test@example.com>
1091 To: <another_user@example.com>
1092 Date: Thu, 28 Sep 2006 00:00:00
1093 Message-Id: @test.nmh
1094 Subject: message/rfc822 attachment
1096 This is an RFC-822 message.
1098 ------- =_aaaaaaaaaa0--
1100 and some garbage at the end
1103 cat >`mhpath new` <<EOF
1104 From: Test <test@example.com>
1105 To: Some User <user@example.com>
1106 Date: Fri, 29 Sep 2006 00:00:00
1107 Message-Id: @test.nmh
1108 Subject: message with message/rfc822 attachment
1110 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
1112 and some garbage before the attachment
1114 ------- =_aaaaaaaaaa0
1115 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1116 Content-Description: 1552
1117 Content-Disposition: attachment; filename="1552"
1119 From: Test <test@example.com>
1120 To: <another_user@example.com>
1121 Date: Thu, 28 Sep 2006 00:00:00
1122 Message-Id: @test.nmh
1123 Subject: message/rfc822 attachment
1125 This is an RFC-822 message.
1127 ------- =_aaaaaaaaaa0--
1129 and some garbage at the end
1132 run_test
'mhfixmsg last -outfile '"$actual" ''
1133 check
"$expected" "$actual"
1136 # check not stripping of CRs from ASCII text context (default)
1137 start_test
"not stripping of CRs from ASCII text context (default)"
1138 cat >"$expected" <<EOF
1140 From: sender@example.com
1141 To: recipient@example.com
1142 Subject: message with CR's
1143 Date: Mon, 29 Apr 2013 11:51:45 -0400
1145 There are two CR-LF pairs at the end of this sentence.
1149 cat >`mhpath new` <<'EOF'
1151 From: sender@example.com
1152 To: recipient@example.com
1153 Subject: message with CR's
1154 Date: Mon, 29 Apr 2013 11:51:45 -0400
1156 There are two CR-LF pairs at the end of this sentence.
1160 run_prog mhfixmsg last
-outfile "$actual"
1161 check
"$expected" "$actual"
1164 # check stripping of CRs from ASCII text context
1165 start_test
"stripping of CRs from ASCII text context"
1166 cat >"$expected" <<EOF
1168 From: sender@example.com
1169 To: recipient@example.com
1170 Subject: message with CR's
1171 Date: Mon, 29 Apr 2013 11:51:45 -0400
1173 There were two CR-LF pairs at the end of this sentence.
1177 cat >`mhpath new` <<'EOF'
1179 From: sender@example.com
1180 To: recipient@example.com
1181 Subject: message with CR's
1182 Date: Mon, 29 Apr 2013 11:51:45 -0400
1184 There were two CR-LF pairs at the end of this sentence.
1188 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1189 check
"$expected" "$actual"
1192 # check -replacetextplain
1193 start_test
"-replacetextplain"
1194 prepare_space
>"$expected" <<EOF
1195 To: recipient@example.com
1196 From: sender@example.com
1197 Subject: mhfixmsg replacement of bad text/plain part test
1199 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1202 Content-Type: text/plain; charset="UTF-8"
1203 Content-Transfer-Encoding: 7bit
1205 Yes, the text/plain part really was empty.
1208 Content-Type: text/html; charset="UTF-8"
1209 Content-Disposition: inline
1212 <title>eticket</title>
1215 Yes, the text/plain part really was empty.
1219 ------=_Part_876302--
1222 cat >`mhpath new` <<'EOF'
1223 To: recipient@example.com
1224 From: sender@example.com
1225 Subject: mhfixmsg replacement of bad text/plain part test
1227 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1230 Content-Type: text/plain; charset="iso-8859-15"
1231 Content-Transfer-Encoding: 7bit
1232 Content-Disposition: inline
1237 Content-Type: text/html; charset="UTF-8"
1238 Content-Disposition: inline
1241 <title>eticket</title>
1244 Yes, the text/plain part really was empty.
1248 ------=_Part_876302--
1251 if [ $can_reformat_texthtml -eq 1 ]; then
1252 #### lynx inserts multiple blank lines, so squeeze them.
1253 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1254 squeeze_lines
> "$actual"
1255 check
"$expected" "$actual" 'ignore space'
1261 # check -noreplacetextplain
1262 start_test
"-noreplacetextplain"
1263 cat >"$expected" <<EOF
1264 To: recipient@example.com
1265 From: sender@example.com
1266 Subject: mhfixmsg replacement of bad text/plain part test
1268 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1271 Content-Type: text/plain; charset="iso-8859-15"
1272 Content-Transfer-Encoding: 7bit
1273 Content-Disposition: inline
1278 Content-Type: text/html; charset="UTF-8"
1279 Content-Disposition: inline
1282 <title>eticket</title>
1285 Yes, the text/plain part really was empty.
1289 ------=_Part_876302--
1292 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1293 check
"$expected" "$actual"
1296 # check removal of extraneous trailing semicolon from header parameter list
1297 start_test
"removal of extraneous trailing semicolon from header parameter list"
1298 cat >"$expected" <<EOF
1299 To: recipient@example.com
1301 From: sender@example.com
1303 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1305 ------- =_aaaaaaaaaa0
1306 Content-Type: text/plain; charset="us-ascii"
1310 ------- =_aaaaaaaaaa0
1311 Content-Type: text/plain; charset="us-ascii";
1313 Content-Description: check folded headers, with and without trailing semicolon
1314 Content-Disposition: attachment;
1319 ------- =_aaaaaaaaaa0--
1322 cat >`mhpath new` <<EOF
1323 To: recipient@example.com
1325 From: sender@example.com
1327 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1329 ------- =_aaaaaaaaaa0
1330 Content-Type: text/plain; charset="us-ascii";
1334 ------- =_aaaaaaaaaa0
1335 Content-Type: text/plain; charset="us-ascii";
1337 Content-Description: check folded headers, with and without trailing semicolon
1338 Content-Disposition: attachment;
1343 ------- =_aaaaaaaaaa0--
1345 run_test
'mhfixmsg last -outfile '"$actual" ''
1346 check
"$expected" "$actual"
1350 start_test
"rmmproc"
1351 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1354 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1355 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1356 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1358 run_test
'mhfixmsg 16' ''
1359 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1360 "${MH_TEST_DIR}/Mail/inbox/16.original"
1364 start_test
"-normmproc"
1365 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1367 run_test
'mhfixmsg 21 -normmproc'
1368 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1369 "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
1373 start_test
"-rmmproc"
1374 run_test
'mhfixmsg 21 -rmmproc true'
1375 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1376 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1377 failed
=`expr ${failed:-0} + 1`
1382 start_test
"-fixtype"
1383 cat >"$expected" <<EOF
1384 To: recipient@example.com
1385 From: sender@example.com
1386 Subject: mhfixmsg with incorrect Content-Type
1388 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1390 ------- =_aaaaaaaaaa0
1391 Content-Type: text/plain; name="plaintext.txt"
1395 ------- =_aaaaaaaaaa0--
1398 cat >`mhpath new` <<EOF
1399 To: recipient@example.com
1400 From: sender@example.com
1401 Subject: mhfixmsg with incorrect Content-Type
1403 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1405 ------- =_aaaaaaaaaa0
1406 Content-Type: application/octet-stream; name="plaintext.txt"
1410 ------- =_aaaaaaaaaa0--
1413 mhfixmsg
-fixtype application
/octet
-stream last
1414 check
"$expected" `mhpath last`
1417 # check default -decodetypes
1418 start_test
"default -decodetypes"
1419 cat >$expected <<EOF
1420 To: recipient@example.com
1421 From: sender@example.com
1422 Subject: mhfixmsg decode test 3
1424 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1426 ------- =_aaaaaaaaaa0
1427 Content-Type: text/plain; charset="iso-8859-1"
1428 Content-Disposition: attachment; filename="test1.txt"
1429 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1430 Content-Transfer-Encoding: 7bit
1432 This is the text/plain part.
1434 ------- =_aaaaaaaaaa0
1435 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1436 Content-Disposition: attachment; filename="test2.txt"
1437 Content-Transfer-Encoding: 7bit
1441 This was the text/html part.
1446 ------- =_aaaaaaaaaa0--
1449 cat >`mhpath new` <<EOF
1450 To: recipient@example.com
1451 From: sender@example.com
1452 Subject: mhfixmsg decode test 3
1454 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1456 ------- =_aaaaaaaaaa0
1457 Content-Type: text/plain; charset="iso-8859-1"
1458 Content-Disposition: attachment; filename="test1.txt"
1459 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1460 Content-Transfer-Encoding: quoted-printable
1462 This is the text/plain part.
1464 ------- =_aaaaaaaaaa0
1465 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1466 Content-Disposition: attachment; filename="test2.txt"
1467 Content-Transfer-Encoding: base64
1469 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1470 Ym9keT4KPC9odG1sPgo=
1472 ------- =_aaaaaaaaaa0--
1474 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1475 check
"$expected" "$actual"
1478 # check -decodetypes text/plain
1479 start_test
"-decodetypes text/plain"
1480 cat >$expected <<EOF
1481 To: recipient@example.com
1482 From: sender@example.com
1483 Subject: mhfixmsg decode test 4
1485 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1487 ------- =_aaaaaaaaaa0
1488 Content-Type: text/plain; charset="iso-8859-1"
1489 Content-Disposition: attachment; filename="test1.txt"
1490 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1491 Content-Transfer-Encoding: 7bit
1493 This is the text/plain part.
1495 ------- =_aaaaaaaaaa0
1496 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1497 Content-Disposition: attachment; filename="test2.txt"
1498 Content-Transfer-Encoding: base64
1500 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1501 CjwvYm9keT4NCjwvaHRtbD4NCg==
1503 ------- =_aaaaaaaaaa0--
1506 cat >`mhpath new` <<EOF
1507 To: recipient@example.com
1508 From: sender@example.com
1509 Subject: mhfixmsg decode test 4
1511 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1513 ------- =_aaaaaaaaaa0
1514 Content-Type: text/plain; charset="iso-8859-1"
1515 Content-Disposition: attachment; filename="test1.txt"
1516 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1517 Content-Transfer-Encoding: quoted-printable
1519 This is the text/plain part.
1521 ------- =_aaaaaaaaaa0
1522 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1523 Content-Disposition: attachment; filename="test2.txt"
1524 Content-Transfer-Encoding: base64
1526 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1527 CjwvYm9keT4NCjwvaHRtbD4NCg==
1529 ------- =_aaaaaaaaaa0--
1531 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1532 check
"$expected" "$actual"
1535 # check -decodetypes attachment/ics
1536 start_test
"-decodetypes attachment/ics"
1537 cat >$expected <<EOF
1538 To: recipient@example.com
1539 From: sender@example.com
1540 Subject: mhfixmsg decode test 5
1542 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1544 ------- =_aaaaaaaaaa0
1545 Content-Type: text/plain; charset="iso-8859-1"
1546 Content-Disposition: attachment; filename="test1.txt"
1547 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1548 Content-Transfer-Encoding: 7bit
1550 This is the text/plain part.
1552 ------- =_aaaaaaaaaa0
1553 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1554 Content-Disposition: attachment; filename="invite.ics"
1555 Content-Transfer-Encoding: 7bit
1561 DTSTAMP:20150101T162400Z
1562 DTSTART:20150105T160000
1563 DTEND:20150105T163000
1564 SUMMARY:4 pm meeting
1568 ------- =_aaaaaaaaaa0--
1571 cat >`mhpath new` <<EOF
1572 To: recipient@example.com
1573 From: sender@example.com
1574 Subject: mhfixmsg decode test 5
1576 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1578 ------- =_aaaaaaaaaa0
1579 Content-Type: text/plain; charset="iso-8859-1"
1580 Content-Disposition: attachment; filename="test1.txt"
1581 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1582 Content-Transfer-Encoding: quoted-printable
1587 ------- =_aaaaaaaaaa0
1588 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1589 Content-Disposition: attachment; filename="invite.ics"
1590 Content-Transfer-Encoding: base64
1592 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1593 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1594 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1595 CkVORDpWQ0FMRU5EQVINCg==
1597 ------- =_aaaaaaaaaa0--
1599 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1600 check
"$expected" "$actual"
1603 # check -decodetypes attachment/ics and -nocrlflinebreaks
1604 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1605 cat >$expected <<EOF
1606 To: recipient@example.com
1607 From: sender@example.com
1608 Subject: mhfixmsg decode test 5
1610 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1612 ------- =_aaaaaaaaaa0
1613 Content-Type: text/plain; charset="iso-8859-1"
1614 Content-Disposition: attachment; filename="test1.txt"
1615 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1616 Content-Transfer-Encoding: 7bit
1618 This is the text/plain part.
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: 7bit
1629 DTSTAMP:20150101T162400Z
1630 DTSTART:20150105T160000
1631 DTEND:20150105T163000
1632 SUMMARY:4 pm meeting
1636 ------- =_aaaaaaaaaa0--
1639 cat >`mhpath new` <<EOF
1640 To: recipient@example.com
1641 From: sender@example.com
1642 Subject: mhfixmsg decode test 5
1644 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1646 ------- =_aaaaaaaaaa0
1647 Content-Type: text/plain; charset="iso-8859-1"
1648 Content-Disposition: attachment; filename="test1.txt"
1649 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1650 Content-Transfer-Encoding: quoted-printable
1655 ------- =_aaaaaaaaaa0
1656 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1657 Content-Disposition: attachment; filename="invite.ics"
1658 Content-Transfer-Encoding: base64
1660 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1661 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1662 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1663 CkVORDpWQ0FMRU5EQVINCg==
1665 ------- =_aaaaaaaaaa0--
1667 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1668 check
"$expected" "$actual"
1671 # check that input is passed through to output when there's a parse error
1672 # (the charset string is missing its closing quote) with -outfile
1673 start_test
"that input is passed through to output when there's a parse error"
1674 cat >"$expected.err" <<EOF
1675 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1677 mhfixmsg: unable to parse message 31
1680 cat >`mhpath new` <<EOF
1681 To: recipient@example.com
1682 From: sender@example.com
1683 Subject: mhfixmsg pass through on parse error
1685 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1687 ------- =_aaaaaaaaaa0
1688 Content-Type: text/plain; charset="iso-8859-1
1689 Content-Disposition: attachment; filename="test1.txt"
1690 Content-Transfer-Encoding: quoted-printable
1695 ------- =_aaaaaaaaaa0--
1698 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1700 #### Expected output is identical to the input message.
1701 check
`mhpath last` "$actual" 'keep first'
1702 check
"$expected.err" "$actual.err"
1705 # check that input is passed through to output when there's a parse error
1706 # (the charset string is missing its closing quote) with -outfile, and
1707 # input from stdin. Don't check err output, because it contains the name
1708 # of a tmp file. It's similar to that of the previous check.
1709 start_test
"that input is passed through to output when there's a parse error"
1711 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1713 #### Expected output is identical to the input message.
1714 check
`mhpath last` "$actual"
1717 start_test
"fix RFC 2047 encoded header parameters"
1718 #### Also, add C-T-E:8bit to the message headers.
1719 cat >"$expected" <<EOF
1720 To: recipient@example.com
1721 From: sender@example.com
1722 Date: Wed, 28 Sep 2016 11:24:28 -0400
1723 Subject: invalid header parameter encoding
1725 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1726 Content-Transfer-Encoding: 8bit
1728 --001a114dd3e8fe9c56053d92f414
1729 Content-Type: text/plain; charset=UTF-8
1733 --001a114dd3e8fe9c56053d92f414
1734 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1735 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1736 Content-Transfer-Encoding: 8bit
1738 This is the first text/plain part, in a subpart. The file name
1741 --001a114dd3e8fe9c56053d92f414--
1744 cat >`mhpath new` <<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
1752 --001a114dd3e8fe9c56053d92f414
1753 Content-Type: text/plain; charset=UTF-8
1757 --001a114dd3e8fe9c56053d92f414
1758 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1759 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1760 Content-Transfer-Encoding: 8bit
1762 This is the first text/plain part, in a subpart. The file name
1765 --001a114dd3e8fe9c56053d92f414--
1767 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1768 check
"$expected" "$actual"
1771 # make sure there are no tmp files left over
1772 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1774 cat >"$expected" <<EOF
1777 check
"$expected" "$actual"