2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"${MH_OBJ_DIR}/test/common.sh"
19 #### Make sure that html-to-text conversion is what we expect.
20 require_locale en_US.utf
-8 en_US.utf8
21 LC_ALL
=en_US.UTF
-8; export LC_ALL
23 expected
="$MH_TEST_DIR/test-mhfixmsg$$.expected"
24 expected_err
="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
25 actual
="$MH_TEST_DIR/test-mhfixmsg$$.actual"
26 actual_err
="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
28 mhn_defaults
="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
30 if grep mhfixmsg
-format-text/html
"${mhn_defaults}" \
32 can_reformat_texthtml
=1
33 if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
35 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
36 #### support testing with non-writeable $HOME, and to not leave
37 #### relics from this test if it is writeable but doesn't already
38 #### have a .w3m, and to not depend on whatever is in that if it
39 #### does already exist, overwrite $HOME if using w3m.
40 HOME
="$MHTMPDIR"; export HOME
43 echo "$0: skipping -reformat check because no text browser was found"
44 can_reformat_texthtml
=0
50 cat >"$expected" <<EOF
51 Usage: mhfixmsg [+folder] [msgs] [switches]
53 -decodetext 8bit|7bit|binary
73 #### Skip nmh intro text.
74 run_prog mhfixmsg
-help | sed '/^$/Q' >"$actual" 2>&1
75 check
"$expected" "$actual"
80 case `mhfixmsg -version` in
82 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
83 failed
=`expr ${failed:-0} + 1`;;
87 # check that non-MIME messages aren't modified
89 start_test
"that non-MIME messages aren't modified, and -outfile"
90 run_test
'mhfixmsg first -outfile '"$actual" ''
91 check
"`mhpath first`" "$actual" 'keep first'
94 # check that non-MIME messages with no bodies aren't modified
96 start_test
"that non-MIME messages with no bodies aren't modified, and -outfile"
97 cat >`mhpath new` <<EOF
98 From: Test <test@example.com>
99 To: Some User <user@example.com>
100 Date: Fri, 29 Sep 2006 00:00:00
101 Message-Id: @test.nmh
102 Subject: message with no body
105 run_test
'mhfixmsg last -outfile '"$actual" ''
106 check
"`mhpath last`" "$actual"
110 start_test
"-nofixcte"
111 cat >"$MH_TEST_DIR"/Mail
/inbox
/11 <<EOF
114 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
115 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
117 Content-Type: MULTIPART/MIXED;
118 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
119 Content-Transfer-Encoding: QUOTED-PRINTABLE
121 This message is in MIME format. The first part should be readable
123 while the remaining parts are likely unreadable without MIME-aware
126 ------=_NextPart_000_0000_00000000.00000000
127 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
128 Content-Transfer-Encoding: 8BIT
130 Some text in swedish.
132 Varf=C3=B6r inte anv=C3=A4nda...
134 ------=_NextPart_000_0000_00000000.00000000--
136 And some text after the last part.
139 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
141 run_test
'mhfixmsg last -nofixcte' ''
142 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
145 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
147 start_test
"-fixcte (enabled by default): fixup of erroneous C-T-E in multipart, and -verbose"
148 cat >"$expected" <<EOF
151 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
152 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
154 Content-Type: MULTIPART/MIXED;
155 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
156 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
157 Content-Transfer-Encoding: 8bit
159 This message is in MIME format. The first part should be readable
161 while the remaining parts are likely unreadable without MIME-aware
164 ------=_NextPart_000_0000_00000000.00000000
165 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
166 Content-Transfer-Encoding: 8BIT
168 Some text in swedish.
170 Varf=C3=B6r inte anv=C3=A4nda...
172 ------=_NextPart_000_0000_00000000.00000000--
174 And some text after the last part.
177 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
178 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
179 QUOTED-PRINTABLE with 8 bit"
180 check
"$expected" "$actual" 'keep first'
183 # check with no options: checks backup
184 start_test
"with no options: checks backup"
185 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
186 folder last
>/dev
/null
187 run_test
'mhfixmsg' ''
188 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
189 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
190 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
193 # check backup with -file
194 start_test
"backup with -file"
195 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
196 folder last
>/dev
/null
197 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
198 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
199 check
"$MH_TEST_DIR"/Mail
/inbox
/,11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
202 # check -reformat (enabled by default): addition of text/plain part
203 # to solitary text/html part
204 start_test
"-reformat (enabled by default): addition of text/plain part"
205 prepare_space
>"$expected" <<EOF
207 From: sender@example.com
208 To: bonquiqui@example.com
210 Date: Sat, 26 Jan 2013 17:37:53 -0500
211 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
213 ------=_nmh-multipart
214 Content-Type: text/plain; charset="Windows-1252"
215 Content-Transfer-Encoding: 8bit
217 Need to go! Need ... to ... go!
219 ------=_nmh-multipart
220 Content-Type: text/html; charset="Windows-1252"
221 Content-Transfer-Encoding: 8bit
225 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
226 <meta name="Generator" content="Microsoft Exchange Server">
227 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
231 <div>Need to go! Need ... to ... go!</div>
235 ------=_nmh-multipart--
238 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
240 From: sender@example.com
241 To: bonquiqui@example.com
243 Date: Sat, 26 Jan 2013 17:37:53 -0500
244 Content-Type: text/html; charset="Windows-1252"
245 Content-Transfer-Encoding: quoted-printable
249 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
251 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
252 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
253 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
257 <div>Need to go! Need ... to ... go!</div>
262 if [ $can_reformat_texthtml -eq 1 ]; then
263 printf '%s\n' "mhfixmsg: 12, insert text/plain part
264 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
267 #### lynx inserts multiple blank lines, so squeeze them.
268 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
269 squeeze_lines
>"$actual"
270 check
"$expected" "$actual" 'ignore space'
271 check
"$expected.err" "$actual.err"
277 # check implicit -file with absolute pathname
278 start_test
"implicit -file with absolute pathname"
279 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
282 # check handling of boundary string that appears in message body
283 start_test
"handling of boundary string that appears in message body"
284 prepare_space
>"$expected" <<EOF
286 From: sender@example.com
287 To: bonquiqui@example.com
289 Date: Sat, 26 Jan 2013 17:37:53 -0500
290 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
292 ------=_nmh-multipart-3
293 Content-Type: text/plain; charset="Windows-1252"
294 Content-Transfer-Encoding: 8bit
296 ------=_nmh-multipart
297 ------=_nmh-multipart-1
298 ------=_nmh-multipart-2
300 ------=_nmh-multipart-3
301 Content-Type: text/html; charset="Windows-1252"
302 Content-Transfer-Encoding: 8bit
306 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
307 <meta name="Generator" content="Microsoft Exchange Server">
308 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
311 ------=_nmh-multipart<br>
312 ------=_nmh-multipart-1<br>
313 ------=_nmh-multipart-2<br>
317 ------=_nmh-multipart-3--
320 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
322 From: sender@example.com
323 To: bonquiqui@example.com
325 Date: Sat, 26 Jan 2013 17:37:53 -0500
326 Content-Type: text/html; charset="Windows-1252"
327 Content-Transfer-Encoding: quoted-printable
331 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
333 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
334 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
335 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
338 ------=3D_nmh-multipart<br>
339 ------=3D_nmh-multipart-1<br>
340 ------=3D_nmh-multipart-2<br>
345 if [ $can_reformat_texthtml -eq 1 ]; then
346 printf '%s\n' "mhfixmsg: 12, insert text/plain part
347 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
350 #### lynx inserts multiple blank lines, so squeeze them.
351 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
352 squeeze_lines
>"$actual"
353 check
"$expected" "$actual" 'ignore space'
354 check
"$expected.err" "$actual.err"
361 start_test
"-nodecode"
362 prepare_space
>"$expected" <<EOF
364 From: sender@example.com
365 To: bonquiqui@example.com
367 Date: Sat, 26 Jan 2013 17:37:53 -0500
368 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
370 ------=_nmh-multipart
371 Content-Type: text/plain; charset="Windows-1252"
372 Content-Transfer-Encoding: 8bit
374 Need to go! Need ... to ... go!
376 ------=_nmh-multipart
377 Content-Type: text/html; charset="Windows-1252"
378 Content-Transfer-Encoding: quoted-printable
382 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
384 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
385 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
386 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
390 <div>Need to go! Need ... to ... go!</div>
394 ------=_nmh-multipart--
397 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
399 From: sender@example.com
400 To: bonquiqui@example.com
402 Date: Sat, 26 Jan 2013 17:37:53 -0500
403 Content-Type: text/html; charset="Windows-1252"
404 Content-Transfer-Encoding: quoted-printable
408 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
410 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
411 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
412 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
416 <div>Need to go! Need ... to ... go!</div>
421 if [ $can_reformat_texthtml -eq 1 ]; then
422 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
424 #### lynx inserts multiple blank lines, so squeeze them.
425 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
426 squeeze_lines
>"$actual"
427 check
"$expected" "$actual" 'ignore space'
428 check
"$expected.err" "$actual.err"
434 # check -decodetext (enabled by default)
435 start_test
"-decodetext (enabled by default)"
436 cat >"$expected" <<EOF
437 To: recipient@example.com
438 From: sender@example.com
439 Subject: mhfixmsg decode test 1
441 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
443 ------- =_aaaaaaaaaa0
444 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
445 Content-Disposition: attachment; filename="test4.txt"
446 Content-Transfer-Encoding: 8bit
448 This is a text/plain part.
450 ------- =_aaaaaaaaaa0--
453 cat >`mhpath new` <<EOF
454 To: recipient@example.com
455 From: sender@example.com
456 Subject: mhfixmsg decode test 1
458 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
460 ------- =_aaaaaaaaaa0
461 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
462 Content-Disposition: attachment; filename="test4.txt"
463 Content-Transfer-Encoding: base64
465 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
467 ------- =_aaaaaaaaaa0--
470 run_prog mhfixmsg last
-outfile "$actual"
471 check
"$expected" "$actual"
474 # check -decodetext with more complicated content structure
475 start_test
"-decodetext with more complicated content structure"
477 To: recipient@example.com
478 From: sender@example.com
479 Subject: mhfixmsg decode test 2
481 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
483 This is additional content before the first subpart of the multipart.
485 ------- =_aaaaaaaaaa0
486 Content-Type: multipart/related;
487 type="text/plain"; boundary="subpart__1.1"
490 Content-Type: text/plain; charset="iso-8859-1"
491 Content-Disposition: attachment; filename="test1.txt"
493 This is the first text/plain part, in a subpart.
497 This is additional content after the last subpart of the multipart.
499 ------- =_aaaaaaaaaa0
500 Content-Type: text/plain; charset="iso-8859-1"
501 Content-Disposition: attachment; filename="test2.txt"
502 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
503 Content-Transfer-Encoding: 8bit
505 This is the second text/plain part.
507 ------- =_aaaaaaaaaa0
508 Content-Type: text/plain; charset="iso-8859-1"
509 Content-Disposition: attachment; filename="test3.txt"
511 This is the third text/plain part.
513 ------- =_aaaaaaaaaa0
514 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
515 Content-Disposition: attachment; filename="test4.txt"
516 Content-Transfer-Encoding: 8bit
518 This is the fourth text/plain part.
520 ------- =_aaaaaaaaaa0--
522 This is additional content after the last subpart of the multipart.
525 cat >`mhpath new` <<EOF
526 To: recipient@example.com
527 From: sender@example.com
528 Subject: mhfixmsg decode test 2
530 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
532 This is additional content before the first subpart of the multipart.
534 ------- =_aaaaaaaaaa0
535 Content-Type: multipart/related;
536 type="text/plain"; boundary="subpart__1.1"
539 Content-Type: text/plain; charset="iso-8859-1"
540 Content-Disposition: attachment; filename="test1.txt"
542 This is the first text/plain part, in a subpart.
546 This is additional content after the last subpart of the multipart.
548 ------- =_aaaaaaaaaa0
549 Content-Type: text/plain; charset="iso-8859-1"
550 Content-Disposition: attachment; filename="test2.txt"
551 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
552 Content-Transfer-Encoding: quoted-printable
554 This is the second text/plain part.
556 ------- =_aaaaaaaaaa0
557 Content-Type: text/plain; charset="iso-8859-1"
558 Content-Disposition: attachment; filename="test3.txt"
560 This is the third text/plain part.
562 ------- =_aaaaaaaaaa0
563 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
564 Content-Disposition: attachment; filename="test4.txt"
565 Content-Transfer-Encoding: base64
567 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
569 ------- =_aaaaaaaaaa0--
571 This is additional content after the last subpart of the multipart.
573 run_prog mhfixmsg last
-outfile "$actual"
574 check
"$expected" "$actual"
577 # check attempted (default, 8 bit) -decodetext of binary text
578 #### Generated the encoded text below with:
579 #### $ printf '\275\262=\274\000\n' | base64
580 start_test
"attempted (default, 8 bit) -decodetext of binary text"
581 cat >`mhpath new` <<EOF
582 To: recipient@example.com
583 From: sender@example.com
584 Subject: mhfixmsg binary decode test
586 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
588 ------- =_aaaaaaaaaa0
589 Content-Type: text/plain; charset=UTF-8; name="nul+square.txt"
590 Content-Transfer-Encoding: base64
594 ------- =_aaaaaaaaaa0--
597 cp -p `mhpath last` "$expected"
598 run_prog mhfixmsg last
599 check
`mhpath last` "$expected" 'keep first'
602 # check for successful decode of a different part with attempted -decodetext
603 # of binary (>998 characters) text
604 start_test
"for successful decode of a different part with attempted -decodetext"
606 To: recipient@example.com
607 From: sender@example.com
608 Subject: mhfixmsg successful decode of text/plain with failed binary decode
610 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
612 ------- =_aaaaaaaaaa0
613 Content-Type: text/plain; charset="iso-8859-1"
614 Content-Transfer-Encoding: 8bit
616 This is a text plain part
618 ------- =_aaaaaaaaaa0
619 Content-Type: text/html; charset="ascii"
620 Content-Transfer-Encoding: base64
621 Content-Disposition: inline
623 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
624 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
625 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
626 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
627 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
628 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
629 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
630 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
631 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
632 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
633 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
634 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
635 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
636 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
637 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
638 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
639 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
640 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
641 ICA8L2JvZHk+PC9odG1sPg==
643 ------- =_aaaaaaaaaa0--
646 cat >`mhpath new` <<EOF
647 To: recipient@example.com
648 From: sender@example.com
649 Subject: mhfixmsg successful decode of text/plain with failed binary decode
651 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
653 ------- =_aaaaaaaaaa0
654 Content-Type: text/plain; charset="iso-8859-1"
655 Content-Transfer-Encoding: base64
657 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
659 ------- =_aaaaaaaaaa0
660 Content-Type: text/html; charset="ascii"
661 Content-Transfer-Encoding: base64
662 Content-Disposition: inline
664 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
665 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
666 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
667 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
668 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
669 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
670 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
671 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
672 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
673 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
674 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
675 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
676 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
677 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
678 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
679 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
680 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
681 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
682 ICA8L2JvZHk+PC9odG1sPg==
684 ------- =_aaaaaaaaaa0--
687 run_prog mhfixmsg
-noreformat last
688 check
`mhpath last` "$expected" 'keep first'
691 # check for successful decode of a different part with -decodetext of binary
692 # (>998 characters) text
693 start_test
"for successful decode of a different part with -decodetext of binary"
695 To: recipient@example.com
696 From: sender@example.com
697 Subject: mhfixmsg successful decode of text/plain with failed binary decode
699 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
701 ------- =_aaaaaaaaaa0
702 Content-Type: text/plain; charset="iso-8859-1"
703 Content-Transfer-Encoding: 8bit
705 This is a text plain part
707 ------- =_aaaaaaaaaa0
708 Content-Type: text/html; charset="ascii"
709 Content-Transfer-Encoding: binary
710 Content-Disposition: inline
712 <html><head><title>long line</title></head><body>This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. </body></html>
714 ------- =_aaaaaaaaaa0--
717 run_prog mhfixmsg
-noreformat -decodetext binary last
718 check
`mhpath last` "$expected"
721 # check -decodetext of binary (containing ASCII NUL) text
722 start_test
"-decodetext of binary (containing ASCII NUL) text"
723 printf "%s\275\262=\274\000%s" "To: recipient@example.com
724 From: sender@example.com
725 Subject: mhfixmsg binary decode test
727 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
729 ------- =_aaaaaaaaaa0
730 Content-Type: text/plain; charset=UTF-8; name=\"nul+square.txt\"
731 Content-Transfer-Encoding: binary
735 ------- =_aaaaaaaaaa0--
737 mhfixmsg last
-decodetext binary
-outfile "$actual"
738 check
"$expected" "$actual"
741 # check that -reformat succeeds when decode of binary text fails
742 start_test
"that -reformat succeeds when decode of binary text fails"
743 prepare_space
>"$expected" <<'EOF'
745 Date: Thu, 11 Apr 2013 02:47:08 -0700
747 From: <sender@example.com>
748 Subject: body requires binary encoding
749 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
751 ------=_nmh-multipart
752 Content-Type: text/plain; charset="ISO-8859-1"
753 Content-Transfer-Encoding: 8bit
758 Vehicle License Fee $1.84
761 ------=_nmh-multipart
762 Content-Type: text/html; charset="ISO-8859-1"
763 Content-Transfer-Encoding: quoted-printable
768 cat >`mhpath new` <<'EOF'
770 Content-Type: text/html; charset="ISO-8859-1"
771 Content-Transfer-Encoding: quoted-printable
772 Date: Thu, 11 Apr 2013 02:47:08 -0700
774 From: <sender@example.com>
775 Subject: body requires binary encoding
778 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
779 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
780 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
781 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
782 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
783 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
784 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
785 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
786 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
787 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
788 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
789 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
790 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
791 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
792 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
793 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
794 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
795 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
796 #333333" size=3D"2">$6.00</font></td></tr>
802 if [ $can_reformat_texthtml -eq 1 ]; then
803 #### lynx inserts multiple blank lines, so squeeze them.
804 #### Truncate to avoid comparing the html portion because it can
805 #### get reformatted.
806 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
807 check
"$expected" "$actual" 'ignore space'
809 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
815 # Also checks preservation of attributes after one (charset) that is
817 start_test
"-textcharset"
818 cat >"$expected" <<EOF
819 To: recipient@example.com
820 From: sender@example.com
821 Subject: mhfixmsg textcharset test
823 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
825 ------- =_aaaaaaaaaa0
826 Content-Type: text/plain; charset="utf-8"; name="square.txt"
827 Content-Disposition: attachment; filename="square.txt"
828 Content-Transfer-Encoding: 8bit
832 ------- =_aaaaaaaaaa0--
835 #### Generated the encoded text below with:
836 #### $ printf '\275\262=\274\n' | base64
837 cat >`mhpath new` <<EOF
838 To: recipient@example.com
839 From: sender@example.com
840 Subject: mhfixmsg textcharset test
842 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
844 ------- =_aaaaaaaaaa0
845 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
846 Content-Disposition: attachment; filename="square.txt"
847 Content-Transfer-Encoding: base64
851 ------- =_aaaaaaaaaa0--
854 if test "$ICONV_ENABLED" -eq 1; then
855 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
856 check
"$expected" "$actual"
858 echo "$0: skipping -textcharset check because nmh was built without iconv"
863 # check -nofixboundary
864 start_test
"-nofixboundary"
865 cat >"$expected" <<EOF
868 cat >`mhpath new` <<EOF
869 Date: Fri, 13 May 2011 08:21:12 -0500
870 Content-Type: multipart/alternative;
871 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
872 Content-Transfer-Encoding: 8bit
874 From: <sender@example.com>
875 To: <recipient@example.com>
876 Subject: mhfixmsg bad boundary test
878 This is a multi-part message in MIME format.
880 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
881 Content-Type: text/plain
883 The boundaries of this part don't match the header boundary.
885 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
888 cp -p `mhpath last` `mhpath new`
890 run_test
'mhfixmsg last -nofixboundary' ''
891 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
894 # check that message is not output when fed through stdin
895 start_test
"that message is not output when fed through stdin"
896 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
897 check
"$expected" "$actual"
898 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
899 "$actual.err" >/dev
/null
; then
902 echo "$0: test failed, output is in $actual.err."
903 failed
=`expr ${failed:-0} + 1`
907 # check fixup of erroneous boundary in multipart (-fixboundary,
908 # enabled by default)
910 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
911 cat >"$expected" <<EOF
912 Date: Fri, 13 May 2011 08:21:12 -0500
913 Content-Type: multipart/alternative;
914 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
915 Content-Transfer-Encoding: 8bit
917 From: <sender@example.com>
918 To: <recipient@example.com>
919 Subject: mhfixmsg bad boundary test
921 This is a multi-part message in MIME format.
923 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
924 Content-Type: text/plain
926 The boundaries of this part don't match the header boundary.
928 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
931 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
932 "mhfixmsg: 18, fix multipart boundary"
933 check
"$expected" "$actual"
936 # check that message is not modified when -fixboundary fails
937 start_test
"that message is not modified when -fixboundary fails"
938 cat >`mhpath new` <<EOF
939 Date: Fri, 13 May 2011 08:21:12 -0500
940 Content-Type: multipart/alternative;
941 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
942 Content-Transfer-Encoding: 8bit
944 From: <sender@example.com>
945 To: <recipient@example.com>
946 Subject: mhfixmsg bad boundary test
948 This is a multi-part message in MIME format.
950 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
951 Content-Type: text/plain
953 The boundary below doesn't match the header boundary.
956 NextPart_000_1781A1A_01CC1147.81EBA8D4--
959 cp -p `mhpath last` "$expected"
960 run_test
"mhfixmsg last -outfile $actual" ''
961 check
"$expected" "$actual"
964 # check that text/plain part is not added to text/html in multipart/related
965 # when it shouldn't be
966 start_test
"that text/plain part is not added to text/html in multipart/related when it shouldn't be"
967 cat >`mhpath new` <<EOF
969 Date: Tue, 26 Feb 2013 18:07:20 -0600
970 Subject: multipart/related, not /alternative
971 Content-Type: multipart/related;
972 type="text/html"; boundary="----=_Part_90310_101292502.1"
974 ------=_Part_90310_101292502.1
975 Content-Type: text/html; charset="us-ascii"
976 Content-Transfer-Encoding: 7bit
979 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
980 <title>HTML Content</title>
983 This is the real content.
987 ------=_Part_90310_101292502.1
988 Content-Type: text/plain; charset="us-ascii"
989 Content-Transfer-Encoding: 7bit
991 Your email client does not support HTML messages
993 ------=_Part_90310_101292502.1--
996 cp -p `mhpath last` "$expected"
998 if [ $can_reformat_texthtml -eq 1 ]; then
999 #### lynx inserts multiple blank lines, so squeeze them.
1000 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1001 check
"$expected" "$actual" 'ignore space'
1007 # check that text/plain part is added to text/html in multipart/related
1009 start_test
"that text/plain part is added to text/html in multipart/related when it should be"
1010 cat >"$expected" <<EOF
1012 Date: Tue, 26 Feb 2013 18:07:20 -0600
1013 Subject: multipart/related, not /alternative
1014 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1016 ------=_Part_90310_101292502.1
1017 Content-Type: text/plain; charset="us-ascii"
1018 Content-Transfer-Encoding: 7bit
1020 This is the real content.
1022 ------=_Part_90310_101292502.1
1023 Content-Type: text/html; charset="us-ascii"
1024 Content-Transfer-Encoding: 7bit
1027 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1028 <title>HTML Content</title>
1031 This is the real content.
1035 ------=_Part_90310_101292502.1--
1038 cat >`mhpath new` <<EOF
1040 Date: Tue, 26 Feb 2013 18:07:20 -0600
1041 Subject: multipart/related, not /alternative
1042 Content-Type: multipart/related;
1043 type="text/html"; boundary="----=_Part_90310_101292502.1"
1045 ------=_Part_90310_101292502.1
1046 Content-Type: text/html; charset="us-ascii"
1047 Content-Transfer-Encoding: 7bit
1050 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1051 <title>HTML Content</title>
1054 This is the real content.
1058 ------=_Part_90310_101292502.1--
1061 if [ $can_reformat_texthtml -eq 1 ]; then
1062 #### lynx inserts multiple blank lines, so squeeze them.
1063 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1064 check
"$expected" "$actual" 'ignore space'
1070 # check handling of rfc822 message type
1071 start_test
"handling of rfc822 message type"
1072 cat >"$expected" <<EOF
1073 From: Test <test@example.com>
1074 To: Some User <user@example.com>
1075 Date: Fri, 29 Sep 2006 00:00:00
1076 Message-Id: @test.nmh
1077 Subject: message with message/rfc822 attachment
1079 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1081 and some garbage before the attachment
1083 ------- =_aaaaaaaaaa0
1084 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1085 Content-Description: 1552
1086 Content-Disposition: attachment; filename="1552"
1088 From: Test <test@example.com>
1089 To: <another_user@example.com>
1090 Date: Thu, 28 Sep 2006 00:00:00
1091 Message-Id: @test.nmh
1092 Subject: message/rfc822 attachment
1094 This is an RFC-822 message.
1096 ------- =_aaaaaaaaaa0--
1098 and some garbage at the end
1101 cat >`mhpath new` <<EOF
1102 From: Test <test@example.com>
1103 To: Some User <user@example.com>
1104 Date: Fri, 29 Sep 2006 00:00:00
1105 Message-Id: @test.nmh
1106 Subject: message with message/rfc822 attachment
1108 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
1110 and some garbage before the attachment
1112 ------- =_aaaaaaaaaa0
1113 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1114 Content-Description: 1552
1115 Content-Disposition: attachment; filename="1552"
1117 From: Test <test@example.com>
1118 To: <another_user@example.com>
1119 Date: Thu, 28 Sep 2006 00:00:00
1120 Message-Id: @test.nmh
1121 Subject: message/rfc822 attachment
1123 This is an RFC-822 message.
1125 ------- =_aaaaaaaaaa0--
1127 and some garbage at the end
1130 run_test
'mhfixmsg last -outfile '"$actual" ''
1131 check
"$expected" "$actual"
1134 # check not stripping of CRs from ASCII text context (default)
1135 start_test
"not stripping of CRs from ASCII text context (default)"
1136 cat >"$expected" <<EOF
1138 From: sender@example.com
1139 To: recipient@example.com
1140 Subject: message with CR's
1141 Date: Mon, 29 Apr 2013 11:51:45 -0400
1143 There are two CR-LF pairs at the end of this sentence.
1147 cat >`mhpath new` <<'EOF'
1149 From: sender@example.com
1150 To: recipient@example.com
1151 Subject: message with CR's
1152 Date: Mon, 29 Apr 2013 11:51:45 -0400
1154 There are two CR-LF pairs at the end of this sentence.
1158 run_prog mhfixmsg last
-outfile "$actual"
1159 check
"$expected" "$actual"
1162 # check stripping of CRs from ASCII text context
1163 start_test
"stripping of CRs from ASCII text context"
1164 cat >"$expected" <<EOF
1166 From: sender@example.com
1167 To: recipient@example.com
1168 Subject: message with CR's
1169 Date: Mon, 29 Apr 2013 11:51:45 -0400
1171 There were two CR-LF pairs at the end of this sentence.
1175 cat >`mhpath new` <<'EOF'
1177 From: sender@example.com
1178 To: recipient@example.com
1179 Subject: message with CR's
1180 Date: Mon, 29 Apr 2013 11:51:45 -0400
1182 There were two CR-LF pairs at the end of this sentence.
1186 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1187 check
"$expected" "$actual"
1190 # check -replacetextplain
1191 start_test
"-replacetextplain"
1192 prepare_space
>"$expected" <<EOF
1193 To: recipient@example.com
1194 From: sender@example.com
1195 Subject: mhfixmsg replacement of bad text/plain part test
1197 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1200 Content-Type: text/plain; charset="UTF-8"
1201 Content-Transfer-Encoding: 8bit
1203 Yes, the text/plain part really was empty.
1206 Content-Type: text/html; charset="UTF-8"
1207 Content-Transfer-Encoding: 8bit
1208 Content-Disposition: inline
1211 <title>eticket</title>
1214 Yes, the text/plain part really was empty.
1218 ------=_Part_876302--
1221 cat >`mhpath new` <<'EOF'
1222 To: recipient@example.com
1223 From: sender@example.com
1224 Subject: mhfixmsg replacement of bad text/plain part test
1226 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1229 Content-Type: text/plain; charset="iso-8859-15"
1230 Content-Transfer-Encoding: 7bit
1231 Content-Disposition: inline
1236 Content-Type: text/html; charset="UTF-8"
1237 Content-Transfer-Encoding: 8bit
1238 Content-Disposition: inline
1241 <title>eticket</title>
1244 Yes, the text/plain part really was empty.
1248 ------=_Part_876302--
1251 if [ $can_reformat_texthtml -eq 1 ]; then
1252 #### lynx inserts multiple blank lines, so squeeze them.
1253 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1254 squeeze_lines
> "$actual"
1255 check
"$expected" "$actual" 'ignore space'
1261 # check -noreplacetextplain
1262 start_test
"-noreplacetextplain"
1263 cat >"$expected" <<EOF
1264 To: recipient@example.com
1265 From: sender@example.com
1266 Subject: mhfixmsg replacement of bad text/plain part test
1268 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1271 Content-Type: text/plain; charset="iso-8859-15"
1272 Content-Transfer-Encoding: 7bit
1273 Content-Disposition: inline
1278 Content-Type: text/html; charset="UTF-8"
1279 Content-Transfer-Encoding: 8bit
1280 Content-Disposition: inline
1283 <title>eticket</title>
1286 Yes, the text/plain part really was empty.
1290 ------=_Part_876302--
1293 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1294 check
"$expected" "$actual"
1297 # check removal of extraneous trailing semicolon from header parameter list
1298 start_test
"removal of extraneous trailing semicolon from header parameter list"
1299 cat >"$expected" <<EOF
1300 To: recipient@example.com
1302 From: sender@example.com
1304 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1306 ------- =_aaaaaaaaaa0
1307 Content-Type: text/plain; charset="us-ascii"
1311 ------- =_aaaaaaaaaa0
1312 Content-Type: text/plain; charset="us-ascii";
1314 Content-Description: check folded headers, with and without trailing semicolon
1315 Content-Disposition: attachment;
1320 ------- =_aaaaaaaaaa0--
1323 cat >`mhpath new` <<EOF
1324 To: recipient@example.com
1326 From: sender@example.com
1328 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1330 ------- =_aaaaaaaaaa0
1331 Content-Type: text/plain; charset="us-ascii";
1335 ------- =_aaaaaaaaaa0
1336 Content-Type: text/plain; charset="us-ascii";
1338 Content-Description: check folded headers, with and without trailing semicolon
1339 Content-Disposition: attachment;
1344 ------- =_aaaaaaaaaa0--
1346 run_test
'mhfixmsg last -outfile '"$actual" ''
1347 check
"$expected" "$actual"
1351 start_test
"rmmproc"
1352 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1355 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1356 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1357 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1359 run_test
'mhfixmsg 16' ''
1360 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1361 "${MH_TEST_DIR}/Mail/inbox/16.original"
1365 start_test
"-normmproc"
1366 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1368 run_test
'mhfixmsg 21 -normmproc'
1369 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1370 "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
1374 start_test
"-rmmproc"
1375 run_test
'mhfixmsg 21 -rmmproc true'
1376 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1377 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1378 failed
=`expr ${failed:-0} + 1`
1383 start_test
"-fixtype"
1384 cat >"$expected" <<EOF
1385 To: recipient@example.com
1386 From: sender@example.com
1387 Subject: mhfixmsg with incorrect Content-Type
1389 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1391 ------- =_aaaaaaaaaa0
1392 Content-Type: text/plain; name="plaintext.txt"
1396 ------- =_aaaaaaaaaa0--
1399 cat >`mhpath new` <<EOF
1400 To: recipient@example.com
1401 From: sender@example.com
1402 Subject: mhfixmsg with incorrect Content-Type
1404 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1406 ------- =_aaaaaaaaaa0
1407 Content-Type: application/octet-stream; name="plaintext.txt"
1411 ------- =_aaaaaaaaaa0--
1414 mhfixmsg
-fixtype application
/octet
-stream last
1415 check
"$expected" `mhpath last`
1418 # check default -decodetypes
1419 start_test
"default -decodetypes"
1420 cat >$expected <<EOF
1421 To: recipient@example.com
1422 From: sender@example.com
1423 Subject: mhfixmsg decode test 3
1425 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1427 ------- =_aaaaaaaaaa0
1428 Content-Type: text/plain; charset="iso-8859-1"
1429 Content-Disposition: attachment; filename="test1.txt"
1430 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1431 Content-Transfer-Encoding: 8bit
1433 This is the text/plain part.
1435 ------- =_aaaaaaaaaa0
1436 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1437 Content-Disposition: attachment; filename="test2.txt"
1438 Content-Transfer-Encoding: 8bit
1442 This was the text/html part.
1447 ------- =_aaaaaaaaaa0--
1450 cat >`mhpath new` <<EOF
1451 To: recipient@example.com
1452 From: sender@example.com
1453 Subject: mhfixmsg decode test 3
1455 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1457 ------- =_aaaaaaaaaa0
1458 Content-Type: text/plain; charset="iso-8859-1"
1459 Content-Disposition: attachment; filename="test1.txt"
1460 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1461 Content-Transfer-Encoding: quoted-printable
1463 This is the text/plain part.
1465 ------- =_aaaaaaaaaa0
1466 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1467 Content-Disposition: attachment; filename="test2.txt"
1468 Content-Transfer-Encoding: base64
1470 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1471 Ym9keT4KPC9odG1sPgo=
1473 ------- =_aaaaaaaaaa0--
1475 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1476 check
"$expected" "$actual"
1479 # check -decodetypes text/plain
1480 start_test
"-decodetypes text/plain"
1481 cat >$expected <<EOF
1482 To: recipient@example.com
1483 From: sender@example.com
1484 Subject: mhfixmsg decode test 4
1486 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1488 ------- =_aaaaaaaaaa0
1489 Content-Type: text/plain; charset="iso-8859-1"
1490 Content-Disposition: attachment; filename="test1.txt"
1491 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1492 Content-Transfer-Encoding: 8bit
1494 This is the text/plain part.
1496 ------- =_aaaaaaaaaa0
1497 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1498 Content-Disposition: attachment; filename="test2.txt"
1499 Content-Transfer-Encoding: base64
1501 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1502 CjwvYm9keT4NCjwvaHRtbD4NCg==
1504 ------- =_aaaaaaaaaa0--
1507 cat >`mhpath new` <<EOF
1508 To: recipient@example.com
1509 From: sender@example.com
1510 Subject: mhfixmsg decode test 4
1512 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1514 ------- =_aaaaaaaaaa0
1515 Content-Type: text/plain; charset="iso-8859-1"
1516 Content-Disposition: attachment; filename="test1.txt"
1517 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1518 Content-Transfer-Encoding: quoted-printable
1520 This is the text/plain part.
1522 ------- =_aaaaaaaaaa0
1523 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1524 Content-Disposition: attachment; filename="test2.txt"
1525 Content-Transfer-Encoding: base64
1527 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1528 CjwvYm9keT4NCjwvaHRtbD4NCg==
1530 ------- =_aaaaaaaaaa0--
1532 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1533 check
"$expected" "$actual"
1536 # check -decodetypes attachment/ics
1537 start_test
"-decodetypes attachment/ics"
1538 cat >$expected <<EOF
1539 To: recipient@example.com
1540 From: sender@example.com
1541 Subject: mhfixmsg decode test 5
1543 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1545 ------- =_aaaaaaaaaa0
1546 Content-Type: text/plain; charset="iso-8859-1"
1547 Content-Disposition: attachment; filename="test1.txt"
1548 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1549 Content-Transfer-Encoding: 8bit
1551 This is the text/plain part.
1553 ------- =_aaaaaaaaaa0
1554 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1555 Content-Disposition: attachment; filename="invite.ics"
1556 Content-Transfer-Encoding: 8bit
1562 DTSTAMP:20150101T162400Z
1563 DTSTART:20150105T160000
1564 DTEND:20150105T163000
1565 SUMMARY:4 pm meeting
1569 ------- =_aaaaaaaaaa0--
1572 cat >`mhpath new` <<EOF
1573 To: recipient@example.com
1574 From: sender@example.com
1575 Subject: mhfixmsg decode test 5
1577 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1579 ------- =_aaaaaaaaaa0
1580 Content-Type: text/plain; charset="iso-8859-1"
1581 Content-Disposition: attachment; filename="test1.txt"
1582 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1583 Content-Transfer-Encoding: quoted-printable
1588 ------- =_aaaaaaaaaa0
1589 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1590 Content-Disposition: attachment; filename="invite.ics"
1591 Content-Transfer-Encoding: base64
1593 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1594 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1595 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1596 CkVORDpWQ0FMRU5EQVINCg==
1598 ------- =_aaaaaaaaaa0--
1600 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1601 check
"$expected" "$actual"
1604 # check -decodetypes attachment/ics and -nocrlflinebreaks
1605 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1606 cat >$expected <<EOF
1607 To: recipient@example.com
1608 From: sender@example.com
1609 Subject: mhfixmsg decode test 5
1611 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1613 ------- =_aaaaaaaaaa0
1614 Content-Type: text/plain; charset="iso-8859-1"
1615 Content-Disposition: attachment; filename="test1.txt"
1616 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1617 Content-Transfer-Encoding: 8bit
1619 This is the text/plain part.
1621 ------- =_aaaaaaaaaa0
1622 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1623 Content-Disposition: attachment; filename="invite.ics"
1624 Content-Transfer-Encoding: 8bit
1630 DTSTAMP:20150101T162400Z
1631 DTSTART:20150105T160000
1632 DTEND:20150105T163000
1633 SUMMARY:4 pm meeting
1637 ------- =_aaaaaaaaaa0--
1640 cat >`mhpath new` <<EOF
1641 To: recipient@example.com
1642 From: sender@example.com
1643 Subject: mhfixmsg decode test 5
1645 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1647 ------- =_aaaaaaaaaa0
1648 Content-Type: text/plain; charset="iso-8859-1"
1649 Content-Disposition: attachment; filename="test1.txt"
1650 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1651 Content-Transfer-Encoding: quoted-printable
1656 ------- =_aaaaaaaaaa0
1657 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1658 Content-Disposition: attachment; filename="invite.ics"
1659 Content-Transfer-Encoding: base64
1661 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1662 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1663 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1664 CkVORDpWQ0FMRU5EQVINCg==
1666 ------- =_aaaaaaaaaa0--
1668 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1669 check
"$expected" "$actual"
1672 # check that input is passed through to output when there's a parse error
1673 # (the charset string is missing its closing quote) with -outfile
1674 start_test
"that input is passed through to output when there's a parse error"
1675 cat >"$expected.err" <<EOF
1676 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1678 mhfixmsg: unable to parse message 31
1681 cat >`mhpath new` <<EOF
1682 To: recipient@example.com
1683 From: sender@example.com
1684 Subject: mhfixmsg pass through on parse error
1686 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1688 ------- =_aaaaaaaaaa0
1689 Content-Type: text/plain; charset="iso-8859-1
1690 Content-Disposition: attachment; filename="test1.txt"
1691 Content-Transfer-Encoding: quoted-printable
1696 ------- =_aaaaaaaaaa0--
1699 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1701 #### Expected output is identical to the input message.
1702 check
`mhpath last` "$actual" 'keep first'
1703 check
"$expected.err" "$actual.err"
1706 # check that input is passed through to output when there's a parse error
1707 # (the charset string is missing its closing quote) with -outfile, and
1708 # input from stdin. Don't check err output, because it contains the name
1709 # of a tmp file. It's similar to that of the previous check.
1710 start_test
"that input is passed through to output when there's a parse error"
1712 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1714 #### Expected output is identical to the input message.
1715 check
`mhpath last` "$actual"
1718 # make sure there are no tmp files left over
1719 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1721 cat >"$expected" <<EOF
1724 check
"$expected" "$actual"