2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"${MH_OBJ_DIR}/test/common.sh"
19 check_exit
'-eq 1' mhfixmsg
- # gcov
21 #### Make sure that html-to-text conversion is what we expect.
22 require_locale en_US.UTF
-8 en_US.UTF8 en_US.utf
-8 en_US.utf8
24 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
25 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
26 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
27 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
29 mhn_defaults
="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
31 if grep mhfixmsg
-format-text/html
"${mhn_defaults}" \
33 can_reformat_texthtml
=1
34 if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
36 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
37 #### support testing with non-writeable $HOME, and to not leave
38 #### relics from this test if it is writeable but doesn't already
39 #### have a .w3m, and to not depend on whatever is in that if it
40 #### does already exist, overwrite $HOME if using w3m.
41 HOME
="$MHTMPDIR"; export HOME
44 echo "$0: skipping -reformat check because no text browser was found"
45 can_reformat_texthtml
=0
51 cat >"$expected" <<EOF
52 Usage: mhfixmsg [+folder] [msgs] [switches]
54 -decodetext 8bit|7bit|binary
74 #### Skip nmh intro text.
75 run_prog mhfixmsg
-help | sed '/^$/,$d' >"$actual" 2>&1
76 check
"$expected" "$actual"
81 case `mhfixmsg -version` in
83 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
84 failed
=`expr ${failed:-0} + 1`;;
88 # check that non-MIME messages aren't modified
90 start_test
"that non-MIME messages aren't modified, and -outfile"
91 run_test
'mhfixmsg first -outfile '"$actual" ''
92 check
"`mhpath first`" "$actual" 'keep first'
95 # check that non-MIME messages with no bodies aren't modified
97 start_test
"that non-MIME messages with no bodies aren't modified, and -outfile"
98 cat >`mhpath new` <<EOF
99 From: Test <test@example.com>
100 To: Some User <user@example.com>
101 Date: Fri, 29 Sep 2006 00:00:00
102 Message-Id: @test.nmh
103 Subject: message with no body
106 run_test
'mhfixmsg last -outfile '"$actual" ''
107 check
"`mhpath last`" "$actual"
111 start_test
"-nofixcte"
112 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
115 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
116 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
118 Content-Type: MULTIPART/MIXED;
119 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
120 Content-Transfer-Encoding: QUOTED-PRINTABLE
122 This message is in MIME format. The first part should be readable
124 while the remaining parts are likely unreadable without MIME-aware
127 ------=_NextPart_000_0000_00000000.00000000
128 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
129 Content-Transfer-Encoding: 8BIT
131 Some text in swedish.
133 Varf=C3=B6r inte anv=C3=A4nda...
135 ------=_NextPart_000_0000_00000000.00000000--
137 And some text after the last part.
140 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
142 run_test
'mhfixmsg last -nofixcte' ''
143 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
146 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
148 start_test
"-fixcte (enabled by default): fixup of erroneous C-T-E in multipart, and -verbose"
149 cat >"$expected" <<EOF
152 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
153 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
155 Content-Type: MULTIPART/MIXED;
156 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
157 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
158 Content-Transfer-Encoding: 8bit
160 This message is in MIME format. The first part should be readable
162 while the remaining parts are likely unreadable without MIME-aware
165 ------=_NextPart_000_0000_00000000.00000000
166 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
167 Content-Transfer-Encoding: 8BIT
169 Some text in swedish.
171 Varf=C3=B6r inte anv=C3=A4nda...
173 ------=_NextPart_000_0000_00000000.00000000--
175 And some text after the last part.
178 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
179 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
180 QUOTED-PRINTABLE with 8 bit"
181 check
"$expected" "$actual" 'keep first'
184 # check with no options: checks backup
185 start_test
"with no options: checks backup"
186 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
187 folder last
>/dev
/null
188 run_test
'mhfixmsg' ''
189 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
190 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
191 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
194 # check backup with -file
195 start_test
"backup with -file"
196 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
197 folder last
>/dev
/null
198 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
199 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
200 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
203 # check -reformat (enabled by default): addition of text/plain part
204 # to solitary text/html part
205 start_test
"-reformat (enabled by default): addition of text/plain part"
206 prepare_space
>"$expected" <<EOF
208 From: sender@example.com
209 To: bonquiqui@example.com
211 Date: Sat, 26 Jan 2013 17:37:53 -0500
212 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
214 ------=_nmh-multipart
215 Content-Type: text/plain; charset="Windows-1252"
216 Content-Transfer-Encoding: 7bit
218 Need to go! Need ... to ... go!
220 ------=_nmh-multipart
221 Content-Type: text/html; charset="Windows-1252"
222 Content-Transfer-Encoding: 7bit
226 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
227 <meta name="Generator" content="Microsoft Exchange Server">
228 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
232 <div>Need to go! Need ... to ... go!</div>
236 ------=_nmh-multipart--
239 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
241 From: sender@example.com
242 To: bonquiqui@example.com
244 Date: Sat, 26 Jan 2013 17:37:53 -0500
245 Content-Type: text/html; charset="Windows-1252"
246 Content-Transfer-Encoding: quoted-printable
250 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
252 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
253 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
254 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
258 <div>Need to go! Need ... to ... go!</div>
263 if [ $can_reformat_texthtml -eq 1 ]; then
264 printf '%s\n' "mhfixmsg: 12, insert text/plain part
265 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
268 #### lynx inserts multiple blank lines, so squeeze them.
269 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
270 squeeze_lines
>"$actual"
271 check
"$expected" "$actual" 'ignore space'
272 check
"$expected.err" "$actual.err"
278 # check implicit -file with absolute pathname
279 start_test
"implicit -file with absolute pathname"
280 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
283 # check handling of boundary string that appears in message body
284 start_test
"handling of boundary string that appears in message body"
285 prepare_space
>"$expected" <<EOF
287 From: sender@example.com
288 To: bonquiqui@example.com
290 Date: Sat, 26 Jan 2013 17:37:53 -0500
291 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
293 ------=_nmh-multipart-3
294 Content-Type: text/plain; charset="Windows-1252"
295 Content-Transfer-Encoding: 7bit
297 ------=_nmh-multipart
298 ------=_nmh-multipart-1
299 ------=_nmh-multipart-2
301 ------=_nmh-multipart-3
302 Content-Type: text/html; charset="Windows-1252"
303 Content-Transfer-Encoding: 7bit
307 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
308 <meta name="Generator" content="Microsoft Exchange Server">
309 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
312 ------=_nmh-multipart<br>
313 ------=_nmh-multipart-1<br>
314 ------=_nmh-multipart-2<br>
318 ------=_nmh-multipart-3--
321 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
323 From: sender@example.com
324 To: bonquiqui@example.com
326 Date: Sat, 26 Jan 2013 17:37:53 -0500
327 Content-Type: text/html; charset="Windows-1252"
328 Content-Transfer-Encoding: quoted-printable
332 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
334 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
335 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
336 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
339 ------=3D_nmh-multipart<br>
340 ------=3D_nmh-multipart-1<br>
341 ------=3D_nmh-multipart-2<br>
346 if [ $can_reformat_texthtml -eq 1 ]; then
347 printf '%s\n' "mhfixmsg: 12, insert text/plain part
348 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
351 #### lynx inserts multiple blank lines, so squeeze them.
352 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
353 squeeze_lines
>"$actual"
354 check
"$expected" "$actual" 'ignore space'
355 check
"$expected.err" "$actual.err"
362 start_test
"-nodecode"
363 prepare_space
>"$expected" <<EOF
365 From: sender@example.com
366 To: bonquiqui@example.com
368 Date: Sat, 26 Jan 2013 17:37:53 -0500
369 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
371 ------=_nmh-multipart
372 Content-Type: text/plain; charset="Windows-1252"
373 Content-Transfer-Encoding: 7bit
375 Need to go! Need ... to ... go!
377 ------=_nmh-multipart
378 Content-Type: text/html; charset="Windows-1252"
379 Content-Transfer-Encoding: quoted-printable
383 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
385 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
386 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
387 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
391 <div>Need to go! Need ... to ... go!</div>
395 ------=_nmh-multipart--
398 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
400 From: sender@example.com
401 To: bonquiqui@example.com
403 Date: Sat, 26 Jan 2013 17:37:53 -0500
404 Content-Type: text/html; charset="Windows-1252"
405 Content-Transfer-Encoding: quoted-printable
409 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
411 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
412 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
413 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
417 <div>Need to go! Need ... to ... go!</div>
422 if [ $can_reformat_texthtml -eq 1 ]; then
423 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
425 #### lynx inserts multiple blank lines, so squeeze them.
426 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
427 squeeze_lines
>"$actual"
428 check
"$expected" "$actual" 'ignore space'
429 check
"$expected.err" "$actual.err"
435 # check -decodetext (enabled by default)
436 start_test
"-decodetext (enabled by default)"
437 cat >"$expected" <<EOF
438 To: recipient@example.com
439 From: sender@example.com
440 Subject: mhfixmsg decode test 1
442 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
444 ------- =_aaaaaaaaaa0
445 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
446 Content-Disposition: attachment; filename="test4.txt"
447 Content-Transfer-Encoding: 7bit
449 This is a text/plain part.
451 ------- =_aaaaaaaaaa0--
454 cat >`mhpath new` <<EOF
455 To: recipient@example.com
456 From: sender@example.com
457 Subject: mhfixmsg decode test 1
459 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
461 ------- =_aaaaaaaaaa0
462 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
463 Content-Disposition: attachment; filename="test4.txt"
464 Content-Transfer-Encoding: base64
466 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
468 ------- =_aaaaaaaaaa0--
471 run_prog mhfixmsg last
-outfile "$actual"
472 check
"$expected" "$actual"
475 # check -decodetext with more complicated content structure
476 start_test
"-decodetext with more complicated content structure"
478 To: recipient@example.com
479 From: sender@example.com
480 Subject: mhfixmsg decode test 2
482 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
484 This is additional content before the first subpart of the multipart.
486 ------- =_aaaaaaaaaa0
487 Content-Type: multipart/related;
488 type="text/plain"; boundary="subpart__1.1"
491 Content-Type: text/plain; charset="iso-8859-1"
492 Content-Disposition: attachment; filename="test1.txt"
494 This is the first text/plain part, in a subpart.
498 This is additional content after the last subpart of the multipart.
500 ------- =_aaaaaaaaaa0
501 Content-Type: text/plain; charset="iso-8859-1"
502 Content-Disposition: attachment; filename="test2.txt"
503 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
504 Content-Transfer-Encoding: 7bit
506 This is the second text/plain part.
508 ------- =_aaaaaaaaaa0
509 Content-Type: text/plain; charset="iso-8859-1"
510 Content-Disposition: attachment; filename="test3.txt"
512 This is the third text/plain part.
514 ------- =_aaaaaaaaaa0
515 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
516 Content-Disposition: attachment; filename="test4.txt"
517 Content-Transfer-Encoding: 7bit
519 This is the fourth text/plain part.
521 ------- =_aaaaaaaaaa0--
523 This is additional content after the last subpart of the multipart.
526 cat >`mhpath new` <<EOF
527 To: recipient@example.com
528 From: sender@example.com
529 Subject: mhfixmsg decode test 2
531 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
533 This is additional content before the first subpart of the multipart.
535 ------- =_aaaaaaaaaa0
536 Content-Type: multipart/related;
537 type="text/plain"; boundary="subpart__1.1"
540 Content-Type: text/plain; charset="iso-8859-1"
541 Content-Disposition: attachment; filename="test1.txt"
543 This is the first text/plain part, in a subpart.
547 This is additional content after the last subpart of the multipart.
549 ------- =_aaaaaaaaaa0
550 Content-Type: text/plain; charset="iso-8859-1"
551 Content-Disposition: attachment; filename="test2.txt"
552 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
553 Content-Transfer-Encoding: quoted-printable
555 This is the second text/plain part.
557 ------- =_aaaaaaaaaa0
558 Content-Type: text/plain; charset="iso-8859-1"
559 Content-Disposition: attachment; filename="test3.txt"
561 This is the third text/plain part.
563 ------- =_aaaaaaaaaa0
564 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
565 Content-Disposition: attachment; filename="test4.txt"
566 Content-Transfer-Encoding: base64
568 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
570 ------- =_aaaaaaaaaa0--
572 This is additional content after the last subpart of the multipart.
574 run_prog mhfixmsg last
-outfile "$actual"
575 check
"$expected" "$actual"
578 # check attempted (default, 8 bit) -decodetext of binary text
579 #### Generated the encoded text below with:
580 #### $ printf '\275\262=\274\000\n' | base64
581 start_test
"attempted (default, 8 bit) -decodetext of binary text"
582 cat >`mhpath new` <<EOF
583 To: recipient@example.com
584 From: sender@example.com
585 Subject: mhfixmsg binary decode test
587 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
589 ------- =_aaaaaaaaaa0
590 Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
591 Content-Transfer-Encoding: base64
595 ------- =_aaaaaaaaaa0--
598 cp -p `mhpath last` "$expected"
599 run_prog mhfixmsg last
600 check
`mhpath last` "$expected" 'keep first'
603 # check for successful decode of a different part with attempted -decodetext
604 # of binary (>998 characters) text
605 start_test
"for successful decode of a different part with attempted -decodetext"
607 To: recipient@example.com
608 From: sender@example.com
609 Subject: mhfixmsg successful decode of text/plain with failed binary decode
611 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
613 ------- =_aaaaaaaaaa0
614 Content-Type: text/plain; charset="iso-8859-1"
615 Content-Transfer-Encoding: 7bit
617 This is a text plain part
619 ------- =_aaaaaaaaaa0
620 Content-Type: text/html; charset="ascii"
621 Content-Transfer-Encoding: base64
622 Content-Disposition: inline
624 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
625 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
626 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
627 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
628 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
629 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
630 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
631 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
632 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
633 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
634 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
635 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
636 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
637 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
638 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
639 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
640 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
641 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
642 ICA8L2JvZHk+PC9odG1sPg==
644 ------- =_aaaaaaaaaa0--
647 cat >`mhpath new` <<EOF
648 To: recipient@example.com
649 From: sender@example.com
650 Subject: mhfixmsg successful decode of text/plain with failed binary decode
652 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
654 ------- =_aaaaaaaaaa0
655 Content-Type: text/plain; charset="iso-8859-1"
656 Content-Transfer-Encoding: base64
658 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
660 ------- =_aaaaaaaaaa0
661 Content-Type: text/html; charset="ascii"
662 Content-Transfer-Encoding: base64
663 Content-Disposition: inline
665 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
666 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
667 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
668 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
669 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
670 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
671 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
672 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
673 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
674 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
675 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
676 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
677 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
678 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
679 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
680 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
681 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
682 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
683 ICA8L2JvZHk+PC9odG1sPg==
685 ------- =_aaaaaaaaaa0--
688 run_prog mhfixmsg
-noreformat last
689 check
`mhpath last` "$expected" 'keep first'
692 # check for successful decode of a different part with -decodetext of binary
693 # (>998 characters) text
694 start_test
"for successful decode of a different part with -decodetext of binary"
696 To: recipient@example.com
697 From: sender@example.com
698 Subject: mhfixmsg successful decode of text/plain with failed binary decode
700 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
701 Content-Transfer-Encoding: binary
703 ------- =_aaaaaaaaaa0
704 Content-Type: text/plain; charset="iso-8859-1"
705 Content-Transfer-Encoding: 7bit
707 This is a text plain part
709 ------- =_aaaaaaaaaa0
710 Content-Type: text/html; charset="ascii"
711 Content-Transfer-Encoding: binary
712 Content-Disposition: inline
714 <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>
716 ------- =_aaaaaaaaaa0--
719 run_prog mhfixmsg
-noreformat -decodetext binary last
720 check
`mhpath last` "$expected"
723 # check -decodetext of binary (containing ASCII NUL) text
724 start_test
"-decodetext of binary (containing ASCII NUL) text"
725 printf "%s\275\262=\274\000%s" "To: recipient@example.com
726 From: sender@example.com
727 Subject: mhfixmsg binary decode test
729 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
730 Content-Transfer-Encoding: binary
732 ------- =_aaaaaaaaaa0
733 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
734 Content-Transfer-Encoding: binary
738 ------- =_aaaaaaaaaa0--
740 mhfixmsg last
-decodetext binary
-outfile "$actual"
741 check
"$expected" "$actual"
744 # check that -reformat succeeds when decode of binary text fails
745 start_test
"that -reformat succeeds when decode of binary text fails"
746 prepare_space
>"$expected" <<'EOF'
748 Date: Thu, 11 Apr 2013 02:47:08 -0700
750 From: <sender@example.com>
751 Subject: body requires binary encoding
752 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
754 ------=_nmh-multipart
755 Content-Type: text/plain; charset="ISO-8859-1"
756 Content-Transfer-Encoding: 7bit
761 Vehicle License Fee $1.84
764 ------=_nmh-multipart
765 Content-Type: text/html; charset="ISO-8859-1"
766 Content-Transfer-Encoding: quoted-printable
771 cat >`mhpath new` <<'EOF'
773 Content-Type: text/html; charset="ISO-8859-1"
774 Content-Transfer-Encoding: quoted-printable
775 Date: Thu, 11 Apr 2013 02:47:08 -0700
777 From: <sender@example.com>
778 Subject: body requires binary encoding
781 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
782 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
783 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
784 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
785 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
786 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
787 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
788 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
789 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
790 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
791 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
792 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
793 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
794 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
795 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
796 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
797 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
798 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
799 #333333" size=3D"2">$6.00</font></td></tr>
805 if [ $can_reformat_texthtml -eq 1 ]; then
806 #### lynx inserts multiple blank lines, so squeeze them.
807 #### Truncate to avoid comparing the html portion because it can
808 #### get reformatted.
809 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
810 check
"$expected" "$actual" 'ignore space'
812 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
818 # Also checks preservation of attributes after one (charset) that is
820 start_test
"-textcharset"
821 cat >"$expected" <<EOF
822 To: recipient@example.com
823 From: sender@example.com
824 Subject: mhfixmsg textcharset test
826 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
827 Content-Transfer-Encoding: 8bit
829 ------- =_aaaaaaaaaa0
830 Content-Type: text/plain; charset="utf-8"; name="square.txt"
831 Content-Disposition: attachment; filename="square.txt"
832 Content-Transfer-Encoding: 8bit
836 ------- =_aaaaaaaaaa0--
839 #### Generated the encoded text below with:
840 #### $ printf '\275\262=\274\n' | base64
841 cat >`mhpath new` <<EOF
842 To: recipient@example.com
843 From: sender@example.com
844 Subject: mhfixmsg textcharset test
846 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
848 ------- =_aaaaaaaaaa0
849 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
850 Content-Disposition: attachment; filename="square.txt"
851 Content-Transfer-Encoding: base64
855 ------- =_aaaaaaaaaa0--
858 if test "$ICONV_ENABLED" -eq 1; then
859 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
860 check
"$expected" "$actual"
862 echo "$0: skipping -textcharset check because nmh was built without iconv"
867 # check -nofixboundary
868 start_test
"-nofixboundary"
869 cat >"$expected" <<EOF
872 cat >`mhpath new` <<EOF
873 Date: Fri, 13 May 2011 08:21:12 -0500
874 Content-Type: multipart/alternative;
875 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
876 Content-Transfer-Encoding: 8bit
878 From: <sender@example.com>
879 To: <recipient@example.com>
880 Subject: mhfixmsg bad boundary test
882 This is a multi-part message in MIME format.
884 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
885 Content-Type: text/plain
887 The boundaries of this part don't match the header boundary.
889 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
892 cp -p `mhpath last` `mhpath new`
894 run_test
'mhfixmsg last -nofixboundary' ''
895 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
898 # check that message is not output when fed through stdin
899 start_test
"that message is not output when fed through stdin"
900 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
901 check
"$expected" "$actual"
902 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
903 "$actual.err" >/dev
/null
; then
906 echo "$0: test failed, output is in $actual.err."
907 failed
=`expr ${failed:-0} + 1`
911 # check fixup of erroneous boundary in multipart (-fixboundary,
912 # enabled by default)
914 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
915 cat >"$expected" <<EOF
916 Date: Fri, 13 May 2011 08:21:12 -0500
917 Content-Type: multipart/alternative;
918 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
919 Content-Transfer-Encoding: 8bit
921 From: <sender@example.com>
922 To: <recipient@example.com>
923 Subject: mhfixmsg bad boundary test
925 This is a multi-part message in MIME format.
927 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
928 Content-Type: text/plain
930 The boundaries of this part don't match the header boundary.
932 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
935 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
936 "mhfixmsg: 18, fix multipart boundary"
937 check
"$expected" "$actual"
940 # check that message is not modified when -fixboundary fails
941 start_test
"that message is not modified when -fixboundary fails"
942 cat >`mhpath new` <<EOF
943 Date: Fri, 13 May 2011 08:21:12 -0500
944 Content-Type: multipart/alternative;
945 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
946 Content-Transfer-Encoding: 8bit
948 From: <sender@example.com>
949 To: <recipient@example.com>
950 Subject: mhfixmsg bad boundary test
952 This is a multi-part message in MIME format.
954 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
955 Content-Type: text/plain
957 The boundary below doesn't match the header boundary.
960 NextPart_000_1781A1A_01CC1147.81EBA8D4--
963 cp -p `mhpath last` "$expected"
964 run_test
"mhfixmsg last -outfile $actual" ''
965 check
"$expected" "$actual"
968 # check that text/plain part is not added to text/html in multipart/related
969 # when it shouldn't be
970 start_test
"that text/plain part is not added to text/html in multipart/related when it shouldn't be"
971 cat >`mhpath new` <<EOF
973 Date: Tue, 26 Feb 2013 18:07:20 -0600
974 Subject: multipart/related, not /alternative
975 Content-Type: multipart/related;
976 type="text/html"; boundary="----=_Part_90310_101292502.1"
978 ------=_Part_90310_101292502.1
979 Content-Type: text/html; charset="us-ascii"
980 Content-Transfer-Encoding: 7bit
983 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
984 <title>HTML Content</title>
987 This is the real content.
991 ------=_Part_90310_101292502.1
992 Content-Type: text/plain; charset="us-ascii"
993 Content-Transfer-Encoding: 7bit
995 Your email client does not support HTML messages
997 ------=_Part_90310_101292502.1--
1000 cp -p `mhpath last` "$expected"
1002 if [ $can_reformat_texthtml -eq 1 ]; then
1003 #### lynx inserts multiple blank lines, so squeeze them.
1004 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1005 check
"$expected" "$actual" 'ignore space'
1011 # check that text/plain part is added to text/html in multipart/related
1013 start_test
"that text/plain part is added to text/html in multipart/related when it should be"
1014 cat >"$expected" <<EOF
1016 Date: Tue, 26 Feb 2013 18:07:20 -0600
1017 Subject: multipart/related, not /alternative
1018 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1020 ------=_Part_90310_101292502.1
1021 Content-Type: text/plain; charset="us-ascii"
1022 Content-Transfer-Encoding: 7bit
1024 This is the real content.
1026 ------=_Part_90310_101292502.1
1027 Content-Type: text/html; charset="us-ascii"
1028 Content-Transfer-Encoding: 7bit
1031 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1032 <title>HTML Content</title>
1035 This is the real content.
1039 ------=_Part_90310_101292502.1--
1042 cat >`mhpath new` <<EOF
1044 Date: Tue, 26 Feb 2013 18:07:20 -0600
1045 Subject: multipart/related, not /alternative
1046 Content-Type: multipart/related;
1047 type="text/html"; boundary="----=_Part_90310_101292502.1"
1049 ------=_Part_90310_101292502.1
1050 Content-Type: text/html; charset="us-ascii"
1051 Content-Transfer-Encoding: 7bit
1054 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1055 <title>HTML Content</title>
1058 This is the real content.
1062 ------=_Part_90310_101292502.1--
1065 if [ $can_reformat_texthtml -eq 1 ]; then
1066 #### lynx inserts multiple blank lines, so squeeze them.
1067 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1068 check
"$expected" "$actual" 'ignore space'
1074 # check handling of rfc822 message type
1075 start_test
"handling of rfc822 message type"
1076 cat >"$expected" <<EOF
1077 From: Test <test@example.com>
1078 To: Some User <user@example.com>
1079 Date: Fri, 29 Sep 2006 00:00:00
1080 Message-Id: @test.nmh
1081 Subject: message with message/rfc822 attachment
1083 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1085 and some garbage before the attachment
1087 ------- =_aaaaaaaaaa0
1088 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1089 Content-Description: 1552
1090 Content-Disposition: attachment; filename="1552"
1092 From: Test <test@example.com>
1093 To: <another_user@example.com>
1094 Date: Thu, 28 Sep 2006 00:00:00
1095 Message-Id: @test.nmh
1096 Subject: message/rfc822 attachment
1098 This is an RFC-822 message.
1100 ------- =_aaaaaaaaaa0--
1102 and some garbage at the end
1105 cat >`mhpath new` <<EOF
1106 From: Test <test@example.com>
1107 To: Some User <user@example.com>
1108 Date: Fri, 29 Sep 2006 00:00:00
1109 Message-Id: @test.nmh
1110 Subject: message with message/rfc822 attachment
1112 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
1114 and some garbage before the attachment
1116 ------- =_aaaaaaaaaa0
1117 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1118 Content-Description: 1552
1119 Content-Disposition: attachment; filename="1552"
1121 From: Test <test@example.com>
1122 To: <another_user@example.com>
1123 Date: Thu, 28 Sep 2006 00:00:00
1124 Message-Id: @test.nmh
1125 Subject: message/rfc822 attachment
1127 This is an RFC-822 message.
1129 ------- =_aaaaaaaaaa0--
1131 and some garbage at the end
1134 run_test
'mhfixmsg last -outfile '"$actual" ''
1135 check
"$expected" "$actual"
1138 # check not stripping of CRs from ASCII text context (default)
1139 start_test
"not stripping of CRs from ASCII text context (default)"
1140 cat >"$expected" <<EOF
1142 From: sender@example.com
1143 To: recipient@example.com
1144 Subject: message with CR's
1145 Date: Mon, 29 Apr 2013 11:51:45 -0400
1147 There are two CR-LF pairs at the end of this sentence.
1151 cat >`mhpath new` <<'EOF'
1153 From: sender@example.com
1154 To: recipient@example.com
1155 Subject: message with CR's
1156 Date: Mon, 29 Apr 2013 11:51:45 -0400
1158 There are two CR-LF pairs at the end of this sentence.
1162 run_prog mhfixmsg last
-outfile "$actual"
1163 check
"$expected" "$actual"
1166 # check stripping of CRs from ASCII text context
1167 start_test
"stripping of CRs from ASCII text context"
1168 cat >"$expected" <<EOF
1170 From: sender@example.com
1171 To: recipient@example.com
1172 Subject: message with CR's
1173 Date: Mon, 29 Apr 2013 11:51:45 -0400
1175 There were two CR-LF pairs at the end of this sentence.
1179 cat >`mhpath new` <<'EOF'
1181 From: sender@example.com
1182 To: recipient@example.com
1183 Subject: message with CR's
1184 Date: Mon, 29 Apr 2013 11:51:45 -0400
1186 There were two CR-LF pairs at the end of this sentence.
1190 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1191 check
"$expected" "$actual"
1194 # check -replacetextplain
1195 start_test
"-replacetextplain"
1196 prepare_space
>"$expected" <<EOF
1197 To: recipient@example.com
1198 From: sender@example.com
1199 Subject: mhfixmsg replacement of bad text/plain part test
1201 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1204 Content-Type: text/plain; charset="UTF-8"
1205 Content-Transfer-Encoding: 7bit
1207 Yes, the text/plain part really was empty.
1210 Content-Type: text/html; charset="UTF-8"
1211 Content-Disposition: inline
1214 <title>eticket</title>
1217 Yes, the text/plain part really was empty.
1221 ------=_Part_876302--
1224 cat >`mhpath new` <<'EOF'
1225 To: recipient@example.com
1226 From: sender@example.com
1227 Subject: mhfixmsg replacement of bad text/plain part test
1229 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1232 Content-Type: text/plain; charset="iso-8859-15"
1233 Content-Transfer-Encoding: 7bit
1234 Content-Disposition: inline
1239 Content-Type: text/html; charset="UTF-8"
1240 Content-Disposition: inline
1243 <title>eticket</title>
1246 Yes, the text/plain part really was empty.
1250 ------=_Part_876302--
1253 if [ $can_reformat_texthtml -eq 1 ]; then
1254 #### lynx inserts multiple blank lines, so squeeze them.
1255 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1256 squeeze_lines
> "$actual"
1257 check
"$expected" "$actual" 'ignore space'
1263 # check -noreplacetextplain
1264 start_test
"-noreplacetextplain"
1265 cat >"$expected" <<EOF
1266 To: recipient@example.com
1267 From: sender@example.com
1268 Subject: mhfixmsg replacement of bad text/plain part test
1270 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1273 Content-Type: text/plain; charset="iso-8859-15"
1274 Content-Transfer-Encoding: 7bit
1275 Content-Disposition: inline
1280 Content-Type: text/html; charset="UTF-8"
1281 Content-Disposition: inline
1284 <title>eticket</title>
1287 Yes, the text/plain part really was empty.
1291 ------=_Part_876302--
1294 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1295 check
"$expected" "$actual"
1298 # check removal of extraneous trailing semicolon from header parameter list
1299 start_test
"removal of extraneous trailing semicolon from header parameter list"
1300 cat >"$expected" <<EOF
1301 To: recipient@example.com
1303 From: sender@example.com
1305 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1307 ------- =_aaaaaaaaaa0
1308 Content-Type: text/plain; charset="us-ascii"
1312 ------- =_aaaaaaaaaa0
1313 Content-Type: text/plain; charset="us-ascii";
1315 Content-Description: check folded headers, with and without trailing semicolon
1316 Content-Disposition: attachment;
1321 ------- =_aaaaaaaaaa0--
1324 cat >`mhpath new` <<EOF
1325 To: recipient@example.com
1327 From: sender@example.com
1329 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1331 ------- =_aaaaaaaaaa0
1332 Content-Type: text/plain; charset="us-ascii";
1336 ------- =_aaaaaaaaaa0
1337 Content-Type: text/plain; charset="us-ascii";
1339 Content-Description: check folded headers, with and without trailing semicolon
1340 Content-Disposition: attachment;
1345 ------- =_aaaaaaaaaa0--
1347 run_test
'mhfixmsg last -outfile '"$actual" ''
1348 check
"$expected" "$actual"
1352 start_test
"rmmproc"
1353 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1356 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1357 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1358 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1360 run_test
'mhfixmsg 16' ''
1361 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1362 "${MH_TEST_DIR}/Mail/inbox/16.original"
1366 start_test
"-normmproc"
1367 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1369 run_test
'mhfixmsg 21 -normmproc'
1370 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1371 "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
1375 start_test
"-rmmproc"
1376 run_test
'mhfixmsg 21 -rmmproc true'
1377 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1378 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1379 failed
=`expr ${failed:-0} + 1`
1384 start_test
"-fixtype"
1385 cat >"$expected" <<EOF
1386 To: recipient@example.com
1387 From: sender@example.com
1388 Subject: mhfixmsg with incorrect Content-Type
1390 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1392 ------- =_aaaaaaaaaa0
1393 Content-Type: text/plain; name="plaintext.txt"
1397 ------- =_aaaaaaaaaa0--
1400 cat >`mhpath new` <<EOF
1401 To: recipient@example.com
1402 From: sender@example.com
1403 Subject: mhfixmsg with incorrect Content-Type
1405 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1407 ------- =_aaaaaaaaaa0
1408 Content-Type: application/octet-stream; name="plaintext.txt"
1412 ------- =_aaaaaaaaaa0--
1415 mhfixmsg
-fixtype application
/octet
-stream last
1416 check
"$expected" `mhpath last`
1419 # check default -decodetypes
1420 start_test
"default -decodetypes"
1421 cat >$expected <<EOF
1422 To: recipient@example.com
1423 From: sender@example.com
1424 Subject: mhfixmsg decode test 3
1426 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1428 ------- =_aaaaaaaaaa0
1429 Content-Type: text/plain; charset="iso-8859-1"
1430 Content-Disposition: attachment; filename="test1.txt"
1431 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1432 Content-Transfer-Encoding: 7bit
1434 This is the text/plain part.
1436 ------- =_aaaaaaaaaa0
1437 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1438 Content-Disposition: attachment; filename="test2.txt"
1439 Content-Transfer-Encoding: 7bit
1443 This was the text/html part.
1448 ------- =_aaaaaaaaaa0--
1451 cat >`mhpath new` <<EOF
1452 To: recipient@example.com
1453 From: sender@example.com
1454 Subject: mhfixmsg decode test 3
1456 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1458 ------- =_aaaaaaaaaa0
1459 Content-Type: text/plain; charset="iso-8859-1"
1460 Content-Disposition: attachment; filename="test1.txt"
1461 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1462 Content-Transfer-Encoding: quoted-printable
1464 This is the text/plain part.
1466 ------- =_aaaaaaaaaa0
1467 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1468 Content-Disposition: attachment; filename="test2.txt"
1469 Content-Transfer-Encoding: base64
1471 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1472 Ym9keT4KPC9odG1sPgo=
1474 ------- =_aaaaaaaaaa0--
1476 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1477 check
"$expected" "$actual"
1480 # check -decodetypes text/plain
1481 start_test
"-decodetypes text/plain"
1482 cat >$expected <<EOF
1483 To: recipient@example.com
1484 From: sender@example.com
1485 Subject: mhfixmsg decode test 4
1487 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1489 ------- =_aaaaaaaaaa0
1490 Content-Type: text/plain; charset="iso-8859-1"
1491 Content-Disposition: attachment; filename="test1.txt"
1492 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1493 Content-Transfer-Encoding: 7bit
1495 This is the text/plain part.
1497 ------- =_aaaaaaaaaa0
1498 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1499 Content-Disposition: attachment; filename="test2.txt"
1500 Content-Transfer-Encoding: base64
1502 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1503 CjwvYm9keT4NCjwvaHRtbD4NCg==
1505 ------- =_aaaaaaaaaa0--
1508 cat >`mhpath new` <<EOF
1509 To: recipient@example.com
1510 From: sender@example.com
1511 Subject: mhfixmsg decode test 4
1513 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1515 ------- =_aaaaaaaaaa0
1516 Content-Type: text/plain; charset="iso-8859-1"
1517 Content-Disposition: attachment; filename="test1.txt"
1518 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1519 Content-Transfer-Encoding: quoted-printable
1521 This is the text/plain part.
1523 ------- =_aaaaaaaaaa0
1524 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1525 Content-Disposition: attachment; filename="test2.txt"
1526 Content-Transfer-Encoding: base64
1528 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1529 CjwvYm9keT4NCjwvaHRtbD4NCg==
1531 ------- =_aaaaaaaaaa0--
1533 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1534 check
"$expected" "$actual"
1537 # check -decodetypes attachment/ics
1538 start_test
"-decodetypes attachment/ics"
1539 cat >$expected <<EOF
1540 To: recipient@example.com
1541 From: sender@example.com
1542 Subject: mhfixmsg decode test 5
1544 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1546 ------- =_aaaaaaaaaa0
1547 Content-Type: text/plain; charset="iso-8859-1"
1548 Content-Disposition: attachment; filename="test1.txt"
1549 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1550 Content-Transfer-Encoding: 7bit
1552 This is the text/plain part.
1554 ------- =_aaaaaaaaaa0
1555 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1556 Content-Disposition: attachment; filename="invite.ics"
1557 Content-Transfer-Encoding: 7bit
1563 DTSTAMP:20150101T162400Z
1564 DTSTART:20150105T160000
1565 DTEND:20150105T163000
1566 SUMMARY:4 pm meeting
1570 ------- =_aaaaaaaaaa0--
1573 cat >`mhpath new` <<EOF
1574 To: recipient@example.com
1575 From: sender@example.com
1576 Subject: mhfixmsg decode test 5
1578 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1580 ------- =_aaaaaaaaaa0
1581 Content-Type: text/plain; charset="iso-8859-1"
1582 Content-Disposition: attachment; filename="test1.txt"
1583 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1584 Content-Transfer-Encoding: quoted-printable
1589 ------- =_aaaaaaaaaa0
1590 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1591 Content-Disposition: attachment; filename="invite.ics"
1592 Content-Transfer-Encoding: base64
1594 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1595 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1596 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1597 CkVORDpWQ0FMRU5EQVINCg==
1599 ------- =_aaaaaaaaaa0--
1601 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1602 check
"$expected" "$actual"
1605 # check -decodetypes attachment/ics and -nocrlflinebreaks
1606 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1607 cat >$expected <<EOF
1608 To: recipient@example.com
1609 From: sender@example.com
1610 Subject: mhfixmsg decode test 5
1612 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1614 ------- =_aaaaaaaaaa0
1615 Content-Type: text/plain; charset="iso-8859-1"
1616 Content-Disposition: attachment; filename="test1.txt"
1617 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1618 Content-Transfer-Encoding: 7bit
1620 This is the text/plain part.
1622 ------- =_aaaaaaaaaa0
1623 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1624 Content-Disposition: attachment; filename="invite.ics"
1625 Content-Transfer-Encoding: 7bit
1631 DTSTAMP:20150101T162400Z
1632 DTSTART:20150105T160000
1633 DTEND:20150105T163000
1634 SUMMARY:4 pm meeting
1638 ------- =_aaaaaaaaaa0--
1641 cat >`mhpath new` <<EOF
1642 To: recipient@example.com
1643 From: sender@example.com
1644 Subject: mhfixmsg decode test 5
1646 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1648 ------- =_aaaaaaaaaa0
1649 Content-Type: text/plain; charset="iso-8859-1"
1650 Content-Disposition: attachment; filename="test1.txt"
1651 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1652 Content-Transfer-Encoding: quoted-printable
1657 ------- =_aaaaaaaaaa0
1658 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1659 Content-Disposition: attachment; filename="invite.ics"
1660 Content-Transfer-Encoding: base64
1662 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1663 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1664 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1665 CkVORDpWQ0FMRU5EQVINCg==
1667 ------- =_aaaaaaaaaa0--
1669 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1670 check
"$expected" "$actual"
1673 # check that input is passed through to output when there's a parse error
1674 # (the charset string is missing its closing quote) with -outfile
1675 start_test
"that input is passed through to output when there's a parse error"
1676 cat >"$expected.err" <<EOF
1677 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1679 mhfixmsg: unable to parse message 31
1682 cat >`mhpath new` <<EOF
1683 To: recipient@example.com
1684 From: sender@example.com
1685 Subject: mhfixmsg pass through on parse error
1687 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1689 ------- =_aaaaaaaaaa0
1690 Content-Type: text/plain; charset="iso-8859-1
1691 Content-Disposition: attachment; filename="test1.txt"
1692 Content-Transfer-Encoding: quoted-printable
1697 ------- =_aaaaaaaaaa0--
1700 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1702 #### Expected output is identical to the input message.
1703 check
`mhpath last` "$actual" 'keep first'
1704 check
"$expected.err" "$actual.err"
1707 # check that input is passed through to output when there's a parse error
1708 # (the charset string is missing its closing quote) with -outfile, and
1709 # input from stdin. Don't check err output, because it contains the name
1710 # of a tmp file. It's similar to that of the previous check.
1711 start_test
"that input is passed through to output when there's a parse error"
1713 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1715 #### Expected output is identical to the input message.
1716 check
`mhpath last` "$actual"
1719 start_test
"fix RFC 2047 encoded header parameters"
1720 #### Also, add C-T-E:8bit to the message headers.
1721 cat >"$expected" <<EOF
1722 To: recipient@example.com
1723 From: sender@example.com
1724 Date: Wed, 28 Sep 2016 11:24:28 -0400
1725 Subject: invalid header parameter encoding
1727 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1728 Content-Transfer-Encoding: 8bit
1730 --001a114dd3e8fe9c56053d92f414
1731 Content-Type: text/plain; charset=UTF-8
1735 --001a114dd3e8fe9c56053d92f414
1736 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1737 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1738 Content-Transfer-Encoding: 8bit
1740 This is the first text/plain part, in a subpart. The file name
1743 --001a114dd3e8fe9c56053d92f414--
1746 cat >`mhpath new` <<EOF
1747 To: recipient@example.com
1748 From: sender@example.com
1749 Date: Wed, 28 Sep 2016 11:24:28 -0400
1750 Subject: invalid header parameter encoding
1752 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1754 --001a114dd3e8fe9c56053d92f414
1755 Content-Type: text/plain; charset=UTF-8
1759 --001a114dd3e8fe9c56053d92f414
1760 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1761 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1762 Content-Transfer-Encoding: 8bit
1764 This is the first text/plain part, in a subpart. The file name
1767 --001a114dd3e8fe9c56053d92f414--
1769 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1770 check
"$expected" "$actual"
1773 # make sure there are no tmp files left over
1774 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1776 cat >"$expected" <<EOF
1779 check
"$expected" "$actual"