2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"${MH_OBJ_DIR}/test/common.sh"
19 check_exit
'-eq 1' mhfixmsg
-
21 #### Make sure that html-to-text conversion is what we expect.
22 require_locale en_US.UTF
-8 en_US.UTF8 en_US.utf
-8 en_US.utf8
24 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
25 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
26 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
27 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
29 mhn_defaults
="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
31 if grep mhfixmsg
-format-text/html
"${mhn_defaults}" \
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
"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
"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 >"`mhpath new`" <<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 >"`mhpath new`" <<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 >"`mhpath last`" <<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
"-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 (without -outfile)
899 start_test
"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
"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
"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
"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 # also, checks -fixboundary
1076 start_test
"handling of rfc822 message type"
1077 cat >"$expected" <<EOF
1078 From: Test <test@example.com>
1079 To: Some User <user@example.com>
1080 Date: Fri, 29 Sep 2006 00:00:00
1081 Message-Id: @test.nmh
1082 Subject: message with message/rfc822 attachment
1084 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1086 and some garbage before the attachment
1088 ------- =_aaaaaaaaaa0
1089 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1090 Content-Description: 1552
1091 Content-Disposition: attachment; filename="1552"
1093 From: Test <test@example.com>
1094 To: <another_user@example.com>
1095 Date: Thu, 28 Sep 2006 00:00:00
1096 Message-Id: @test.nmh
1097 Subject: message/rfc822 attachment
1099 This is an RFC-822 message.
1101 ------- =_aaaaaaaaaa0--
1103 and some garbage at the end
1106 cat >"`mhpath new`" <<EOF
1107 From: Test <test@example.com>
1108 To: Some User <user@example.com>
1109 Date: Fri, 29 Sep 2006 00:00:00
1110 Message-Id: @test.nmh
1111 Subject: message with message/rfc822 attachment
1113 Content-Type: multipart/mixed; boundary="----- =badboundary"
1115 and some garbage before the attachment
1117 ------- =_aaaaaaaaaa0
1118 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1119 Content-Description: 1552
1120 Content-Disposition: attachment; filename="1552"
1122 From: Test <test@example.com>
1123 To: <another_user@example.com>
1124 Date: Thu, 28 Sep 2006 00:00:00
1125 Message-Id: @test.nmh
1126 Subject: message/rfc822 attachment
1128 This is an RFC-822 message.
1130 ------- =_aaaaaaaaaa0--
1132 and some garbage at the end
1135 run_test
'mhfixmsg last -outfile '"$actual" ''
1136 check
"$expected" "$actual"
1139 # check not stripping of CRs from ASCII text context (default)
1140 start_test
"not stripping of CRs from ASCII text context (default)"
1141 cat >"$expected" <<EOF
1143 From: sender@example.com
1144 To: recipient@example.com
1145 Subject: message with CR's
1146 Date: Mon, 29 Apr 2013 11:51:45 -0400
1148 There are two CR-LF pairs at the end of this sentence.
1152 cat >"`mhpath new`" <<'EOF'
1154 From: sender@example.com
1155 To: recipient@example.com
1156 Subject: message with CR's
1157 Date: Mon, 29 Apr 2013 11:51:45 -0400
1159 There are two CR-LF pairs at the end of this sentence.
1163 run_prog mhfixmsg last
-outfile "$actual"
1164 check
"$expected" "$actual"
1167 # check stripping of CRs from ASCII text context
1168 start_test
"stripping of CRs from ASCII text context"
1169 cat >"$expected" <<EOF
1171 From: sender@example.com
1172 To: recipient@example.com
1173 Subject: message with CR's
1174 Date: Mon, 29 Apr 2013 11:51:45 -0400
1176 There were two CR-LF pairs at the end of this sentence.
1180 cat >"`mhpath new`" <<'EOF'
1182 From: sender@example.com
1183 To: recipient@example.com
1184 Subject: message with CR's
1185 Date: Mon, 29 Apr 2013 11:51:45 -0400
1187 There were two CR-LF pairs at the end of this sentence.
1191 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1192 check
"$expected" "$actual"
1195 # check -replacetextplain
1196 start_test
"-replacetextplain"
1197 prepare_space
>"$expected" <<EOF
1198 To: recipient@example.com
1199 From: sender@example.com
1200 Subject: mhfixmsg replacement of bad text/plain part test
1202 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1205 Content-Type: text/plain; charset="UTF-8"
1206 Content-Transfer-Encoding: 7bit
1208 Yes, the text/plain part really was empty.
1211 Content-Type: text/html; charset="UTF-8"
1212 Content-Disposition: inline
1215 <title>eticket</title>
1218 Yes, the text/plain part really was empty.
1222 ------=_Part_876302--
1225 cat >"`mhpath new`" <<'EOF'
1226 To: recipient@example.com
1227 From: sender@example.com
1228 Subject: mhfixmsg replacement of bad text/plain part test
1230 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1233 Content-Type: text/plain; charset="iso-8859-15"
1234 Content-Transfer-Encoding: 7bit
1235 Content-Disposition: inline
1240 Content-Type: text/html; charset="UTF-8"
1241 Content-Disposition: inline
1244 <title>eticket</title>
1247 Yes, the text/plain part really was empty.
1251 ------=_Part_876302--
1254 if [ $can_reformat_texthtml -eq 1 ]; then
1255 #### lynx inserts multiple blank lines, so squeeze them.
1256 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1257 squeeze_lines
> "$actual"
1258 check
"$expected" "$actual" 'ignore space'
1264 # check -noreplacetextplain
1265 start_test
"-noreplacetextplain"
1266 cat >"$expected" <<EOF
1267 To: recipient@example.com
1268 From: sender@example.com
1269 Subject: mhfixmsg replacement of bad text/plain part test
1271 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1274 Content-Type: text/plain; charset="iso-8859-15"
1275 Content-Transfer-Encoding: 7bit
1276 Content-Disposition: inline
1281 Content-Type: text/html; charset="UTF-8"
1282 Content-Disposition: inline
1285 <title>eticket</title>
1288 Yes, the text/plain part really was empty.
1292 ------=_Part_876302--
1295 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1296 check
"$expected" "$actual"
1299 # check removal of extraneous trailing semicolon from header parameter list
1300 start_test
"removal of extraneous trailing semicolon from header parameter list"
1301 cat >"$expected" <<EOF
1302 To: recipient@example.com
1304 From: sender@example.com
1306 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1308 ------- =_aaaaaaaaaa0
1309 Content-Type: text/plain; charset="us-ascii"
1313 ------- =_aaaaaaaaaa0
1314 Content-Type: text/plain; charset="us-ascii";
1316 Content-Description: check folded headers, with and without trailing semicolon
1317 Content-Disposition: attachment;
1322 ------- =_aaaaaaaaaa0--
1325 cat >"`mhpath new`" <<EOF
1326 To: recipient@example.com
1328 From: sender@example.com
1330 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1332 ------- =_aaaaaaaaaa0
1333 Content-Type: text/plain; charset="us-ascii";
1337 ------- =_aaaaaaaaaa0
1338 Content-Type: text/plain; charset="us-ascii";
1340 Content-Description: check folded headers, with and without trailing semicolon
1341 Content-Disposition: attachment;
1346 ------- =_aaaaaaaaaa0--
1348 run_test
'mhfixmsg last -outfile '"$actual" ''
1349 check
"$expected" "$actual"
1353 start_test
"rmmproc"
1354 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1357 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1358 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1359 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1361 run_test
'mhfixmsg 16' ''
1362 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1363 "${MH_TEST_DIR}/Mail/inbox/16.original"
1367 start_test
"-normmproc"
1368 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1370 run_test
'mhfixmsg 21 -normmproc'
1371 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1372 "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
1376 start_test
"-rmmproc"
1377 run_test
'mhfixmsg 21 -rmmproc true'
1378 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1379 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1380 failed
=`expr ${failed:-0} + 1`
1385 start_test
"-fixtype"
1386 cat >"$expected" <<EOF
1387 To: recipient@example.com
1388 From: sender@example.com
1389 Subject: mhfixmsg with incorrect Content-Type
1391 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1393 ------- =_aaaaaaaaaa0
1394 Content-Type: text/plain; name="plaintext.txt"
1398 ------- =_aaaaaaaaaa0--
1401 cat >"`mhpath new`" <<EOF
1402 To: recipient@example.com
1403 From: sender@example.com
1404 Subject: mhfixmsg with incorrect Content-Type
1406 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1408 ------- =_aaaaaaaaaa0
1409 Content-Type: application/octet-stream; name="plaintext.txt"
1413 ------- =_aaaaaaaaaa0--
1416 mhfixmsg
-fixtype application
/octet
-stream last
1417 check
"$expected" "`mhpath last`"
1420 # check default -decodetypes
1421 start_test
"default -decodetypes"
1422 cat >$expected <<EOF
1423 To: recipient@example.com
1424 From: sender@example.com
1425 Subject: mhfixmsg decode test 3
1427 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1429 ------- =_aaaaaaaaaa0
1430 Content-Type: text/plain; charset="iso-8859-1"
1431 Content-Disposition: attachment; filename="test1.txt"
1432 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1433 Content-Transfer-Encoding: 7bit
1435 This is the text/plain part.
1437 ------- =_aaaaaaaaaa0
1438 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1439 Content-Disposition: attachment; filename="test2.txt"
1440 Content-Transfer-Encoding: 7bit
1444 This was the text/html part.
1449 ------- =_aaaaaaaaaa0--
1452 cat >"`mhpath new`" <<EOF
1453 To: recipient@example.com
1454 From: sender@example.com
1455 Subject: mhfixmsg decode test 3
1457 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1459 ------- =_aaaaaaaaaa0
1460 Content-Type: text/plain; charset="iso-8859-1"
1461 Content-Disposition: attachment; filename="test1.txt"
1462 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1463 Content-Transfer-Encoding: quoted-printable
1465 This is the text/plain part.
1467 ------- =_aaaaaaaaaa0
1468 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1469 Content-Disposition: attachment; filename="test2.txt"
1470 Content-Transfer-Encoding: base64
1472 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1473 Ym9keT4KPC9odG1sPgo=
1475 ------- =_aaaaaaaaaa0--
1477 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1478 check
"$expected" "$actual"
1481 # check -decodetypes text/plain
1482 start_test
"-decodetypes text/plain"
1483 cat >$expected <<EOF
1484 To: recipient@example.com
1485 From: sender@example.com
1486 Subject: mhfixmsg decode test 4
1488 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1490 ------- =_aaaaaaaaaa0
1491 Content-Type: text/plain; charset="iso-8859-1"
1492 Content-Disposition: attachment; filename="test1.txt"
1493 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1494 Content-Transfer-Encoding: 7bit
1496 This is the text/plain part.
1498 ------- =_aaaaaaaaaa0
1499 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1500 Content-Disposition: attachment; filename="test2.txt"
1501 Content-Transfer-Encoding: base64
1503 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1504 CjwvYm9keT4NCjwvaHRtbD4NCg==
1506 ------- =_aaaaaaaaaa0--
1509 cat >"`mhpath new`" <<EOF
1510 To: recipient@example.com
1511 From: sender@example.com
1512 Subject: mhfixmsg decode test 4
1514 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1516 ------- =_aaaaaaaaaa0
1517 Content-Type: text/plain; charset="iso-8859-1"
1518 Content-Disposition: attachment; filename="test1.txt"
1519 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1520 Content-Transfer-Encoding: quoted-printable
1522 This is the text/plain part.
1524 ------- =_aaaaaaaaaa0
1525 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1526 Content-Disposition: attachment; filename="test2.txt"
1527 Content-Transfer-Encoding: base64
1529 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1530 CjwvYm9keT4NCjwvaHRtbD4NCg==
1532 ------- =_aaaaaaaaaa0--
1534 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1535 check
"$expected" "$actual"
1538 # check -decodetypes attachment/ics
1539 start_test
"-decodetypes attachment/ics"
1540 cat >$expected <<EOF
1541 To: recipient@example.com
1542 From: sender@example.com
1543 Subject: mhfixmsg decode test 5
1545 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1547 ------- =_aaaaaaaaaa0
1548 Content-Type: text/plain; charset="iso-8859-1"
1549 Content-Disposition: attachment; filename="test1.txt"
1550 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1551 Content-Transfer-Encoding: 7bit
1553 This is the text/plain part.
1555 ------- =_aaaaaaaaaa0
1556 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1557 Content-Disposition: attachment; filename="invite.ics"
1558 Content-Transfer-Encoding: 7bit
1564 DTSTAMP:20150101T162400Z
1565 DTSTART:20150105T160000
1566 DTEND:20150105T163000
1567 SUMMARY:4 pm meeting
1571 ------- =_aaaaaaaaaa0--
1574 cat >"`mhpath new`" <<EOF
1575 To: recipient@example.com
1576 From: sender@example.com
1577 Subject: mhfixmsg decode test 5
1579 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1581 ------- =_aaaaaaaaaa0
1582 Content-Type: text/plain; charset="iso-8859-1"
1583 Content-Disposition: attachment; filename="test1.txt"
1584 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1585 Content-Transfer-Encoding: quoted-printable
1590 ------- =_aaaaaaaaaa0
1591 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1592 Content-Disposition: attachment; filename="invite.ics"
1593 Content-Transfer-Encoding: base64
1595 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1596 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1597 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1598 CkVORDpWQ0FMRU5EQVINCg==
1600 ------- =_aaaaaaaaaa0--
1602 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1603 check
"$expected" "$actual"
1606 # check -decodetypes attachment/ics and -nocrlflinebreaks
1607 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1608 cat >$expected <<EOF
1609 To: recipient@example.com
1610 From: sender@example.com
1611 Subject: mhfixmsg decode test 5
1613 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1615 ------- =_aaaaaaaaaa0
1616 Content-Type: text/plain; charset="iso-8859-1"
1617 Content-Disposition: attachment; filename="test1.txt"
1618 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1619 Content-Transfer-Encoding: 7bit
1621 This is the text/plain part.
1623 ------- =_aaaaaaaaaa0
1624 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1625 Content-Disposition: attachment; filename="invite.ics"
1626 Content-Transfer-Encoding: 7bit
1632 DTSTAMP:20150101T162400Z
1633 DTSTART:20150105T160000
1634 DTEND:20150105T163000
1635 SUMMARY:4 pm meeting
1639 ------- =_aaaaaaaaaa0--
1642 cat >"`mhpath new`" <<EOF
1643 To: recipient@example.com
1644 From: sender@example.com
1645 Subject: mhfixmsg decode test 5
1647 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1649 ------- =_aaaaaaaaaa0
1650 Content-Type: text/plain; charset="iso-8859-1"
1651 Content-Disposition: attachment; filename="test1.txt"
1652 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1653 Content-Transfer-Encoding: quoted-printable
1658 ------- =_aaaaaaaaaa0
1659 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1660 Content-Disposition: attachment; filename="invite.ics"
1661 Content-Transfer-Encoding: base64
1663 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1664 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1665 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1666 CkVORDpWQ0FMRU5EQVINCg==
1668 ------- =_aaaaaaaaaa0--
1670 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1671 check
"$expected" "$actual"
1674 # check that input is passed through to output when there's a parse error
1675 # (the charset string is missing its closing quote) with -outfile
1676 start_test
"input is passed through to output when there's a parse error"
1677 cat >"$expected.err" <<EOF
1678 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1680 mhfixmsg: unable to parse message 31
1683 cat >"`mhpath new`" <<EOF
1684 To: recipient@example.com
1685 From: sender@example.com
1686 Subject: mhfixmsg pass through on parse error
1688 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1690 ------- =_aaaaaaaaaa0
1691 Content-Type: text/plain; charset="iso-8859-1
1692 Content-Disposition: attachment; filename="test1.txt"
1693 Content-Transfer-Encoding: quoted-printable
1698 ------- =_aaaaaaaaaa0--
1701 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1703 #### Expected output is identical to the input message.
1704 check
"`mhpath last`" "$actual" 'keep first'
1705 check
"$expected.err" "$actual.err"
1708 # check that input is passed through to output when there's a parse error
1709 # (the charset string is missing its closing quote) with -outfile, and
1710 # input from stdin. Don't check err output, because it contains the name
1711 # of a tmp file. It's similar to that of the previous check.
1712 start_test
"input is passed through to output when there's a parse error"
1714 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1716 #### Expected output is identical to the input message.
1717 check
"`mhpath last`" "$actual" 'keep first'
1720 start_test
"pass through message with relative folder path with parse error"
1721 #### Factor out leading portion of current folder path and make it relative.
1724 run_prog mhfixmsg
+.
/`mhpath | sed "s%^$pwd/%%"` last
-out - >"$actual" 2>/dev
/null
1726 folder
-f +inbox
>/dev
/null
1727 #### Expected output is identical to the input message.
1728 check
"`mhpath last`" "$actual"
1731 start_test
"fix RFC 2047 encoded header parameters"
1732 #### Also, add C-T-E:8bit to the message headers.
1733 cat >"$expected" <<EOF
1734 To: recipient@example.com
1735 From: sender@example.com
1736 Date: Wed, 28 Sep 2016 11:24:28 -0400
1737 Subject: invalid header parameter encoding
1739 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1740 Content-Transfer-Encoding: 8bit
1742 --001a114dd3e8fe9c56053d92f414
1743 Content-Type: text/plain; charset=UTF-8
1747 --001a114dd3e8fe9c56053d92f414
1748 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1749 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1750 Content-Transfer-Encoding: 8bit
1752 This is the first text/plain part, in a subpart. The file name
1755 --001a114dd3e8fe9c56053d92f414--
1758 cat >"`mhpath new`" <<EOF
1759 To: recipient@example.com
1760 From: sender@example.com
1761 Date: Wed, 28 Sep 2016 11:24:28 -0400
1762 Subject: invalid header parameter encoding
1764 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1766 --001a114dd3e8fe9c56053d92f414
1767 Content-Type: text/plain; charset=UTF-8
1771 --001a114dd3e8fe9c56053d92f414
1772 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1773 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1774 Content-Transfer-Encoding: 8bit
1776 This is the first text/plain part, in a subpart. The file name
1779 --001a114dd3e8fe9c56053d92f414--
1781 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1782 check
"$expected" "$actual"
1785 # make sure there are no tmp files left over
1786 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1788 cat >"$expected" <<EOF
1791 check
"$expected" "$actual"