2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"${MH_OBJ_DIR}/test/common.sh"
19 #### Make sure that html-to-text conversion is what we expect.
20 require_locale en_US.utf
-8 en_US.utf8
21 LC_ALL
=en_US.UTF
-8; export LC_ALL
23 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
24 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
25 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
26 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
28 mhn_defaults
="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
30 if grep mhfixmsg
-format-text/html
"${mhn_defaults}" \
32 can_reformat_texthtml
=1
33 if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
35 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
36 #### support testing with non-writeable $HOME, and to not leave
37 #### relics from this test if it is writeable but doesn't already
38 #### have a .w3m, and to not depend on whatever is in that if it
39 #### does already exist, overwrite $HOME if using w3m.
40 HOME
="$MHTMPDIR"; export HOME
43 echo "$0: skipping -reformat check because no text browser was found"
44 can_reformat_texthtml
=0
50 cat >"$expected" <<EOF
51 Usage: mhfixmsg [+folder] [msgs] [switches]
53 -decodetext 8bit|7bit|binary
73 run_prog mhfixmsg
-help >"$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: 8bit
216 Need to go! Need ... to ... go!
218 ------=_nmh-multipart
219 Content-Type: text/html; charset="Windows-1252"
220 Content-Transfer-Encoding: 8bit
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: 8bit
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: 8bit
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: 8bit
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: 8bit
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: 8bit
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: 8bit
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: 8bit
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"
700 ------- =_aaaaaaaaaa0
701 Content-Type: text/plain; charset="iso-8859-1"
702 Content-Transfer-Encoding: 8bit
704 This is a text plain part
706 ------- =_aaaaaaaaaa0
707 Content-Type: text/html; charset="ascii"
708 Content-Transfer-Encoding: binary
709 Content-Disposition: inline
711 <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>
713 ------- =_aaaaaaaaaa0--
716 run_prog mhfixmsg
-noreformat -decodetext binary last
717 check
`mhpath last` "$expected"
720 # check -decodetext of binary (containing ASCII NUL) text
721 start_test
"-decodetext of binary (containing ASCII NUL) text"
722 printf "%s\275\262=\274\000%s" "To: recipient@example.com
723 From: sender@example.com
724 Subject: mhfixmsg binary decode test
726 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
728 ------- =_aaaaaaaaaa0
729 Content-Type: text/plain; charset=UTF-8; name=\"nul+square.txt\"
730 Content-Transfer-Encoding: binary
734 ------- =_aaaaaaaaaa0--
736 mhfixmsg last
-decodetext binary
-outfile "$actual"
737 check
"$expected" "$actual"
740 # check that -reformat succeeds when decode of binary text fails
741 start_test
"that -reformat succeeds when decode of binary text fails"
742 prepare_space
>"$expected" <<'EOF'
744 Date: Thu, 11 Apr 2013 02:47:08 -0700
746 From: <sender@example.com>
747 Subject: body requires binary encoding
748 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
750 ------=_nmh-multipart
751 Content-Type: text/plain; charset="ISO-8859-1"
752 Content-Transfer-Encoding: 8bit
757 Vehicle License Fee $1.84
760 ------=_nmh-multipart
761 Content-Type: text/html; charset="ISO-8859-1"
762 Content-Transfer-Encoding: quoted-printable
767 cat >`mhpath new` <<'EOF'
769 Content-Type: text/html; charset="ISO-8859-1"
770 Content-Transfer-Encoding: quoted-printable
771 Date: Thu, 11 Apr 2013 02:47:08 -0700
773 From: <sender@example.com>
774 Subject: body requires binary encoding
777 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
778 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
779 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
780 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
781 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
782 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
783 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
784 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
785 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
786 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
787 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
788 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
789 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
790 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
791 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
792 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
793 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
794 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
795 #333333" size=3D"2">$6.00</font></td></tr>
801 if [ $can_reformat_texthtml -eq 1 ]; then
802 #### lynx inserts multiple blank lines, so squeeze them.
803 #### Truncate to avoid comparing the html portion because it can
804 #### get reformatted.
805 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
806 check
"$expected" "$actual" 'ignore space'
808 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
814 # Also checks preservation of attributes after one (charset) that is
816 start_test
"-textcharset"
817 cat >"$expected" <<EOF
818 To: recipient@example.com
819 From: sender@example.com
820 Subject: mhfixmsg textcharset test
822 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
824 ------- =_aaaaaaaaaa0
825 Content-Type: text/plain; charset="utf-8"; name="square.txt"
826 Content-Disposition: attachment; filename="square.txt"
827 Content-Transfer-Encoding: 8bit
831 ------- =_aaaaaaaaaa0--
834 #### Generated the encoded text below with:
835 #### $ printf '\275\262=\274\n' | base64
836 cat >`mhpath new` <<EOF
837 To: recipient@example.com
838 From: sender@example.com
839 Subject: mhfixmsg textcharset test
841 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
843 ------- =_aaaaaaaaaa0
844 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
845 Content-Disposition: attachment; filename="square.txt"
846 Content-Transfer-Encoding: base64
850 ------- =_aaaaaaaaaa0--
853 if test "$ICONV_ENABLED" -eq 1; then
854 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
855 check
"$expected" "$actual"
857 echo "$0: skipping -textcharset check because nmh was built without iconv"
862 # check -nofixboundary
863 start_test
"-nofixboundary"
864 cat >"$expected" <<EOF
867 cat >`mhpath new` <<EOF
868 Date: Fri, 13 May 2011 08:21:12 -0500
869 Content-Type: multipart/alternative;
870 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
871 Content-Transfer-Encoding: 8bit
873 From: <sender@example.com>
874 To: <recipient@example.com>
875 Subject: mhfixmsg bad boundary test
877 This is a multi-part message in MIME format.
879 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
880 Content-Type: text/plain
882 The boundaries of this part don't match the header boundary.
884 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
887 cp -p `mhpath last` `mhpath new`
889 run_test
'mhfixmsg last -nofixboundary' ''
890 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
893 # check that message is not output when fed through stdin
894 start_test
"that message is not output when fed through stdin"
895 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
896 check
"$expected" "$actual"
897 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
898 "$actual.err" >/dev
/null
; then
901 echo "$0: test failed, output is in $actual.err."
902 failed
=`expr ${failed:-0} + 1`
906 # check fixup of erroneous boundary in multipart (-fixboundary,
907 # enabled by default)
909 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
910 cat >"$expected" <<EOF
911 Date: Fri, 13 May 2011 08:21:12 -0500
912 Content-Type: multipart/alternative;
913 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
914 Content-Transfer-Encoding: 8bit
916 From: <sender@example.com>
917 To: <recipient@example.com>
918 Subject: mhfixmsg bad boundary test
920 This is a multi-part message in MIME format.
922 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
923 Content-Type: text/plain
925 The boundaries of this part don't match the header boundary.
927 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
930 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
931 "mhfixmsg: 18, fix multipart boundary"
932 check
"$expected" "$actual"
935 # check that message is not modified when -fixboundary fails
936 start_test
"that message is not modified when -fixboundary fails"
937 cat >`mhpath new` <<EOF
938 Date: Fri, 13 May 2011 08:21:12 -0500
939 Content-Type: multipart/alternative;
940 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
941 Content-Transfer-Encoding: 8bit
943 From: <sender@example.com>
944 To: <recipient@example.com>
945 Subject: mhfixmsg bad boundary test
947 This is a multi-part message in MIME format.
949 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
950 Content-Type: text/plain
952 The boundary below doesn't match the header boundary.
955 NextPart_000_1781A1A_01CC1147.81EBA8D4--
958 cp -p `mhpath last` "$expected"
959 run_test
"mhfixmsg last -outfile $actual" ''
960 check
"$expected" "$actual"
963 # check that text/plain part is not added to text/html in multipart/related
964 # when it shouldn't be
965 start_test
"that text/plain part is not added to text/html in multipart/related when it shouldn't be"
966 cat >`mhpath new` <<EOF
968 Date: Tue, 26 Feb 2013 18:07:20 -0600
969 Subject: multipart/related, not /alternative
970 Content-Type: multipart/related;
971 type="text/html"; boundary="----=_Part_90310_101292502.1"
973 ------=_Part_90310_101292502.1
974 Content-Type: text/html; charset="us-ascii"
975 Content-Transfer-Encoding: 7bit
978 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
979 <title>HTML Content</title>
982 This is the real content.
986 ------=_Part_90310_101292502.1
987 Content-Type: text/plain; charset="us-ascii"
988 Content-Transfer-Encoding: 7bit
990 Your email client does not support HTML messages
992 ------=_Part_90310_101292502.1--
995 cp -p `mhpath last` "$expected"
997 if [ $can_reformat_texthtml -eq 1 ]; then
998 #### lynx inserts multiple blank lines, so squeeze them.
999 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1000 check
"$expected" "$actual" 'ignore space'
1006 # check that text/plain part is added to text/html in multipart/related
1008 start_test
"that text/plain part is added to text/html in multipart/related when it should be"
1009 cat >"$expected" <<EOF
1011 Date: Tue, 26 Feb 2013 18:07:20 -0600
1012 Subject: multipart/related, not /alternative
1013 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1015 ------=_Part_90310_101292502.1
1016 Content-Type: text/plain; charset="us-ascii"
1017 Content-Transfer-Encoding: 7bit
1019 This is the real content.
1021 ------=_Part_90310_101292502.1
1022 Content-Type: text/html; charset="us-ascii"
1023 Content-Transfer-Encoding: 7bit
1026 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1027 <title>HTML Content</title>
1030 This is the real content.
1034 ------=_Part_90310_101292502.1--
1037 cat >`mhpath new` <<EOF
1039 Date: Tue, 26 Feb 2013 18:07:20 -0600
1040 Subject: multipart/related, not /alternative
1041 Content-Type: multipart/related;
1042 type="text/html"; boundary="----=_Part_90310_101292502.1"
1044 ------=_Part_90310_101292502.1
1045 Content-Type: text/html; charset="us-ascii"
1046 Content-Transfer-Encoding: 7bit
1049 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1050 <title>HTML Content</title>
1053 This is the real content.
1057 ------=_Part_90310_101292502.1--
1060 if [ $can_reformat_texthtml -eq 1 ]; then
1061 #### lynx inserts multiple blank lines, so squeeze them.
1062 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1063 check
"$expected" "$actual" 'ignore space'
1069 # check handling of rfc822 message type
1070 start_test
"handling of rfc822 message type"
1071 cat >"$expected" <<EOF
1072 From: Test <test@example.com>
1073 To: Some User <user@example.com>
1074 Date: Fri, 29 Sep 2006 00:00:00
1075 Message-Id: @test.nmh
1076 Subject: message with message/rfc822 attachment
1078 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1080 and some garbage before the attachment
1082 ------- =_aaaaaaaaaa0
1083 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1084 Content-Description: 1552
1085 Content-Disposition: attachment; filename="1552"
1087 From: Test <test@example.com>
1088 To: <another_user@example.com>
1089 Date: Thu, 28 Sep 2006 00:00:00
1090 Message-Id: @test.nmh
1091 Subject: message/rfc822 attachment
1093 This is an RFC-822 message.
1095 ------- =_aaaaaaaaaa0--
1097 and some garbage at the end
1100 cat >`mhpath new` <<EOF
1101 From: Test <test@example.com>
1102 To: Some User <user@example.com>
1103 Date: Fri, 29 Sep 2006 00:00:00
1104 Message-Id: @test.nmh
1105 Subject: message with message/rfc822 attachment
1107 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
1109 and some garbage before the attachment
1111 ------- =_aaaaaaaaaa0
1112 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1113 Content-Description: 1552
1114 Content-Disposition: attachment; filename="1552"
1116 From: Test <test@example.com>
1117 To: <another_user@example.com>
1118 Date: Thu, 28 Sep 2006 00:00:00
1119 Message-Id: @test.nmh
1120 Subject: message/rfc822 attachment
1122 This is an RFC-822 message.
1124 ------- =_aaaaaaaaaa0--
1126 and some garbage at the end
1129 run_test
'mhfixmsg last -outfile '"$actual" ''
1130 check
"$expected" "$actual"
1133 # check not stripping of CRs from ASCII text context (default)
1134 start_test
"not stripping of CRs from ASCII text context (default)"
1135 cat >"$expected" <<EOF
1137 From: sender@example.com
1138 To: recipient@example.com
1139 Subject: message with CR's
1140 Date: Mon, 29 Apr 2013 11:51:45 -0400
1142 There are two CR-LF pairs at the end of this sentence.
1146 cat >`mhpath new` <<'EOF'
1148 From: sender@example.com
1149 To: recipient@example.com
1150 Subject: message with CR's
1151 Date: Mon, 29 Apr 2013 11:51:45 -0400
1153 There are two CR-LF pairs at the end of this sentence.
1157 run_prog mhfixmsg last
-outfile "$actual"
1158 check
"$expected" "$actual"
1161 # check stripping of CRs from ASCII text context
1162 start_test
"stripping of CRs from ASCII text context"
1163 cat >"$expected" <<EOF
1165 From: sender@example.com
1166 To: recipient@example.com
1167 Subject: message with CR's
1168 Date: Mon, 29 Apr 2013 11:51:45 -0400
1170 There were two CR-LF pairs at the end of this sentence.
1174 cat >`mhpath new` <<'EOF'
1176 From: sender@example.com
1177 To: recipient@example.com
1178 Subject: message with CR's
1179 Date: Mon, 29 Apr 2013 11:51:45 -0400
1181 There were two CR-LF pairs at the end of this sentence.
1185 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1186 check
"$expected" "$actual"
1189 # check -replacetextplain
1190 start_test
"-replacetextplain"
1191 prepare_space
>"$expected" <<EOF
1192 To: recipient@example.com
1193 From: sender@example.com
1194 Subject: mhfixmsg replacement of bad text/plain part test
1196 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1199 Content-Type: text/plain; charset="UTF-8"
1200 Content-Transfer-Encoding: 8bit
1202 Yes, the text/plain part really was empty.
1205 Content-Type: text/html; charset="UTF-8"
1206 Content-Transfer-Encoding: 8bit
1207 Content-Disposition: inline
1210 <title>eticket</title>
1213 Yes, the text/plain part really was empty.
1217 ------=_Part_876302--
1220 cat >`mhpath new` <<'EOF'
1221 To: recipient@example.com
1222 From: sender@example.com
1223 Subject: mhfixmsg replacement of bad text/plain part test
1225 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1228 Content-Type: text/plain; charset="iso-8859-15"
1229 Content-Transfer-Encoding: 7bit
1230 Content-Disposition: inline
1235 Content-Type: text/html; charset="UTF-8"
1236 Content-Transfer-Encoding: 8bit
1237 Content-Disposition: inline
1240 <title>eticket</title>
1243 Yes, the text/plain part really was empty.
1247 ------=_Part_876302--
1250 if [ $can_reformat_texthtml -eq 1 ]; then
1251 #### lynx inserts multiple blank lines, so squeeze them.
1252 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1253 squeeze_lines
> "$actual"
1254 check
"$expected" "$actual" 'ignore space'
1260 # check -noreplacetextplain
1261 start_test
"-noreplacetextplain"
1262 cat >"$expected" <<EOF
1263 To: recipient@example.com
1264 From: sender@example.com
1265 Subject: mhfixmsg replacement of bad text/plain part test
1267 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1270 Content-Type: text/plain; charset="iso-8859-15"
1271 Content-Transfer-Encoding: 7bit
1272 Content-Disposition: inline
1277 Content-Type: text/html; charset="UTF-8"
1278 Content-Transfer-Encoding: 8bit
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: 8bit
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: 8bit
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: 8bit
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: 8bit
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: 8bit
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: 8bit
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: 8bit
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 # make sure there are no tmp files left over
1718 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1720 cat >"$expected" <<EOF
1723 check
"$expected" "$actual"