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}" >/dev
/null
; then
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 '/^$/,$d' >"$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
"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
"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 >"`mhpath new`" <<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: 7bit
217 Need to go! Need ... to ... go!
219 ------=_nmh-multipart
220 Content-Type: text/html; charset="Windows-1252"
221 Content-Transfer-Encoding: 7bit
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 >"`mhpath new`" <<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: 7bit
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: 7bit
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 >"`mhpath last`" <<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: 7bit
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: 7bit
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: 7bit
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: 7bit
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: 7bit
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"
700 Content-Transfer-Encoding: binary
702 ------- =_aaaaaaaaaa0
703 Content-Type: text/plain; charset="iso-8859-1"
704 Content-Transfer-Encoding: 7bit
706 This is a text plain part
708 ------- =_aaaaaaaaaa0
709 Content-Type: text/html; charset="ascii"
710 Content-Transfer-Encoding: binary
711 Content-Disposition: inline
713 <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>
715 ------- =_aaaaaaaaaa0--
718 run_prog mhfixmsg
-noreformat -decodetext binary last
719 check
"`mhpath last`" "$expected"
722 # check -decodetext of binary (containing ASCII NUL) text
723 start_test
"-decodetext of binary (containing ASCII NUL) text"
724 printf "%s\275\262=\274\000%s" "To: recipient@example.com
725 From: sender@example.com
726 Subject: mhfixmsg binary decode test
728 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
729 Content-Transfer-Encoding: binary
731 ------- =_aaaaaaaaaa0
732 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
733 Content-Transfer-Encoding: binary
737 ------- =_aaaaaaaaaa0--
739 mhfixmsg last
-decodetext binary
-outfile "$actual"
740 check
"$expected" "$actual"
743 # check that -reformat succeeds when decode of binary text fails
744 start_test
"-reformat succeeds when decode of binary text fails"
745 prepare_space
>"$expected" <<'EOF'
747 Date: Thu, 11 Apr 2013 02:47:08 -0700
749 From: <sender@example.com>
750 Subject: body requires binary encoding
751 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
753 ------=_nmh-multipart
754 Content-Type: text/plain; charset="ISO-8859-1"
755 Content-Transfer-Encoding: 7bit
760 Vehicle License Fee $1.84
763 ------=_nmh-multipart
764 Content-Type: text/html; charset="ISO-8859-1"
765 Content-Transfer-Encoding: quoted-printable
770 cat >"`mhpath new`" <<'EOF'
772 Content-Type: text/html; charset="ISO-8859-1"
773 Content-Transfer-Encoding: quoted-printable
774 Date: Thu, 11 Apr 2013 02:47:08 -0700
776 From: <sender@example.com>
777 Subject: body requires binary encoding
780 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
781 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
782 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
783 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
784 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
785 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
786 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
787 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
788 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
789 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
790 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
791 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
792 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
793 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
794 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
795 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
796 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
797 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
798 #333333" size=3D"2">$6.00</font></td></tr>
804 if [ $can_reformat_texthtml -eq 1 ]; then
805 #### lynx inserts multiple blank lines, so squeeze them.
806 #### Truncate to avoid comparing the html portion because it can
807 #### get reformatted.
808 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
809 check
"$expected" "$actual" 'ignore space'
811 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
817 # Also checks preservation of attributes after one (charset) that is
819 start_test
"-textcharset"
820 cat >"$expected" <<EOF
821 To: recipient@example.com
822 From: sender@example.com
823 Subject: mhfixmsg textcharset test
825 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
826 Content-Transfer-Encoding: 8bit
828 ------- =_aaaaaaaaaa0
829 Content-Type: text/plain; charset="utf-8"; name="square.txt"
830 Content-Disposition: attachment; filename="square.txt"
831 Content-Transfer-Encoding: 8bit
835 ------- =_aaaaaaaaaa0--
838 #### Generated the encoded text below with:
839 #### $ printf '\275\262=\274\n' | base64
840 cat >"`mhpath new`" <<EOF
841 To: recipient@example.com
842 From: sender@example.com
843 Subject: mhfixmsg textcharset test
845 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
847 ------- =_aaaaaaaaaa0
848 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
849 Content-Disposition: attachment; filename="square.txt"
850 Content-Transfer-Encoding: base64
854 ------- =_aaaaaaaaaa0--
857 if test "$ICONV_ENABLED" -eq 1; then
858 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
859 check
"$expected" "$actual"
861 echo "$0: skipping -textcharset check because nmh was built without iconv"
866 # check -nofixboundary
867 start_test
"-nofixboundary"
868 cat >"$expected" <<EOF
871 cat >"`mhpath new`" <<EOF
872 Date: Fri, 13 May 2011 08:21:12 -0500
873 Content-Type: multipart/alternative;
874 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
875 Content-Transfer-Encoding: 8bit
877 From: <sender@example.com>
878 To: <recipient@example.com>
879 Subject: mhfixmsg bad boundary test
881 This is a multi-part message in MIME format.
883 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
884 Content-Type: text/plain
886 The boundaries of this part don't match the header boundary.
888 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
891 cp -p "`mhpath last`" "`mhpath new`"
893 run_test
'mhfixmsg last -nofixboundary' ''
894 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
897 # check that message is not output when fed through stdin (without -outfile)
898 start_test
"message is not output when fed through stdin"
899 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
900 check
"$expected" "$actual"
901 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
902 "$actual.err" >/dev
/null
; then
905 echo "$0: test failed, output is in $actual.err."
906 failed
=`expr ${failed:-0} + 1`
910 # check fixup of erroneous boundary in multipart (-fixboundary,
911 # enabled by default)
913 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
914 cat >"$expected" <<EOF
915 Date: Fri, 13 May 2011 08:21:12 -0500
916 Content-Type: multipart/alternative;
917 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
918 Content-Transfer-Encoding: 8bit
920 From: <sender@example.com>
921 To: <recipient@example.com>
922 Subject: mhfixmsg bad boundary test
924 This is a multi-part message in MIME format.
926 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
927 Content-Type: text/plain
929 The boundaries of this part don't match the header boundary.
931 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
934 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
935 "mhfixmsg: 18, fix multipart boundary"
936 check
"$expected" "$actual"
939 # check that message is not modified when -fixboundary fails
940 start_test
"message is not modified when -fixboundary fails"
941 cat >"`mhpath new`" <<EOF
942 Date: Fri, 13 May 2011 08:21:12 -0500
943 Content-Type: multipart/alternative;
944 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
945 Content-Transfer-Encoding: 8bit
947 From: <sender@example.com>
948 To: <recipient@example.com>
949 Subject: mhfixmsg bad boundary test
951 This is a multi-part message in MIME format.
953 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
954 Content-Type: text/plain
956 The boundary below doesn't match the header boundary.
959 NextPart_000_1781A1A_01CC1147.81EBA8D4--
962 cp -p "`mhpath last`" "$expected"
963 run_test
"mhfixmsg last -outfile $actual" ''
964 check
"$expected" "$actual"
967 # check that text/plain part is not added to text/html in multipart/related
968 # when it shouldn't be
969 start_test
"text/plain part is not added to text/html in multipart/related when it shouldn't be"
970 cat >"`mhpath new`" <<EOF
972 Date: Tue, 26 Feb 2013 18:07:20 -0600
973 Subject: multipart/related, not /alternative
974 Content-Type: multipart/related;
975 type="text/html"; boundary="----=_Part_90310_101292502.1"
977 ------=_Part_90310_101292502.1
978 Content-Type: text/html; charset="us-ascii"
979 Content-Transfer-Encoding: 7bit
982 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
983 <title>HTML Content</title>
986 This is the real content.
990 ------=_Part_90310_101292502.1
991 Content-Type: text/plain; charset="us-ascii"
992 Content-Transfer-Encoding: 7bit
994 Your email client does not support HTML messages
996 ------=_Part_90310_101292502.1--
999 cp -p "`mhpath last`" "$expected"
1001 if [ $can_reformat_texthtml -eq 1 ]; then
1002 #### lynx inserts multiple blank lines, so squeeze them.
1003 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1004 check
"$expected" "$actual" 'ignore space'
1010 # check that text/plain part is added to text/html in multipart/related
1012 start_test
"text/plain part is added to text/html in multipart/related when it should be"
1013 cat >"$expected" <<EOF
1015 Date: Tue, 26 Feb 2013 18:07:20 -0600
1016 Subject: multipart/related, not /alternative
1017 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1019 ------=_Part_90310_101292502.1
1020 Content-Type: text/plain; charset="us-ascii"
1021 Content-Transfer-Encoding: 7bit
1023 This is the real content.
1025 ------=_Part_90310_101292502.1
1026 Content-Type: text/html; charset="us-ascii"
1027 Content-Transfer-Encoding: 7bit
1030 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1031 <title>HTML Content</title>
1034 This is the real content.
1038 ------=_Part_90310_101292502.1--
1041 cat >"`mhpath new`" <<EOF
1043 Date: Tue, 26 Feb 2013 18:07:20 -0600
1044 Subject: multipart/related, not /alternative
1045 Content-Type: multipart/related;
1046 type="text/html"; boundary="----=_Part_90310_101292502.1"
1048 ------=_Part_90310_101292502.1
1049 Content-Type: text/html; charset="us-ascii"
1050 Content-Transfer-Encoding: 7bit
1053 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1054 <title>HTML Content</title>
1057 This is the real content.
1061 ------=_Part_90310_101292502.1--
1064 if [ $can_reformat_texthtml -eq 1 ]; then
1065 #### lynx inserts multiple blank lines, so squeeze them.
1066 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1067 check
"$expected" "$actual" 'ignore space'
1073 # check handling of rfc822 message type
1074 # also, checks -fixboundary
1075 start_test
"handling of rfc822 message type"
1076 cat >"$expected" <<EOF
1077 From: Test <test@example.com>
1078 To: Some User <user@example.com>
1079 Date: Fri, 29 Sep 2006 00:00:00
1080 Message-Id: @test.nmh
1081 Subject: message with message/rfc822 attachment
1083 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1085 and some garbage before the attachment
1087 ------- =_aaaaaaaaaa0
1088 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1089 Content-Description: 1552
1090 Content-Disposition: attachment; filename="1552"
1092 From: Test <test@example.com>
1093 To: <another_user@example.com>
1094 Date: Thu, 28 Sep 2006 00:00:00
1095 Message-Id: @test.nmh
1096 Subject: message/rfc822 attachment
1098 This is an RFC-822 message.
1100 ------- =_aaaaaaaaaa0--
1102 and some garbage at the end
1105 cat >"`mhpath new`" <<EOF
1106 From: Test <test@example.com>
1107 To: Some User <user@example.com>
1108 Date: Fri, 29 Sep 2006 00:00:00
1109 Message-Id: @test.nmh
1110 Subject: message with message/rfc822 attachment
1112 Content-Type: multipart/mixed; boundary="----- =badboundary"
1114 and some garbage before the attachment
1116 ------- =_aaaaaaaaaa0
1117 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1118 Content-Description: 1552
1119 Content-Disposition: attachment; filename="1552"
1121 From: Test <test@example.com>
1122 To: <another_user@example.com>
1123 Date: Thu, 28 Sep 2006 00:00:00
1124 Message-Id: @test.nmh
1125 Subject: message/rfc822 attachment
1127 This is an RFC-822 message.
1129 ------- =_aaaaaaaaaa0--
1131 and some garbage at the end
1134 run_test
'mhfixmsg last -outfile '"$actual" ''
1135 check
"$expected" "$actual"
1138 # check not stripping of CRs from ASCII text context (default)
1139 start_test
"not stripping of CRs from ASCII text context (default)"
1140 cat >"$expected" <<EOF
1142 From: sender@example.com
1143 To: recipient@example.com
1144 Subject: message with CR's
1145 Date: Mon, 29 Apr 2013 11:51:45 -0400
1147 There are two CR-LF pairs at the end of this sentence.
1151 cat >"`mhpath new`" <<'EOF'
1153 From: sender@example.com
1154 To: recipient@example.com
1155 Subject: message with CR's
1156 Date: Mon, 29 Apr 2013 11:51:45 -0400
1158 There are two CR-LF pairs at the end of this sentence.
1162 run_prog mhfixmsg last
-outfile "$actual"
1163 check
"$expected" "$actual"
1166 # check stripping of CRs from ASCII text context
1167 start_test
"stripping of CRs from ASCII text context"
1168 cat >"$expected" <<EOF
1170 From: sender@example.com
1171 To: recipient@example.com
1172 Subject: message with CR's
1173 Date: Mon, 29 Apr 2013 11:51:45 -0400
1175 There were two CR-LF pairs at the end of this sentence.
1179 cat >"`mhpath new`" <<'EOF'
1181 From: sender@example.com
1182 To: recipient@example.com
1183 Subject: message with CR's
1184 Date: Mon, 29 Apr 2013 11:51:45 -0400
1186 There were two CR-LF pairs at the end of this sentence.
1190 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1191 check
"$expected" "$actual"
1194 # check -replacetextplain
1195 start_test
"-replacetextplain"
1196 prepare_space
>"$expected" <<EOF
1197 To: recipient@example.com
1198 From: sender@example.com
1199 Subject: mhfixmsg replacement of bad text/plain part test
1201 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1204 Content-Type: text/plain; charset="UTF-8"
1205 Content-Transfer-Encoding: 7bit
1207 Yes, the text/plain part really was empty.
1210 Content-Type: text/html; charset="UTF-8"
1211 Content-Disposition: inline
1214 <title>eticket</title>
1217 Yes, the text/plain part really was empty.
1221 ------=_Part_876302--
1224 cat >"`mhpath new`" <<'EOF'
1225 To: recipient@example.com
1226 From: sender@example.com
1227 Subject: mhfixmsg replacement of bad text/plain part test
1229 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1232 Content-Type: text/plain; charset="iso-8859-15"
1233 Content-Transfer-Encoding: 7bit
1234 Content-Disposition: inline
1239 Content-Type: text/html; charset="UTF-8"
1240 Content-Disposition: inline
1243 <title>eticket</title>
1246 Yes, the text/plain part really was empty.
1250 ------=_Part_876302--
1253 if [ $can_reformat_texthtml -eq 1 ]; then
1254 #### lynx inserts multiple blank lines, so squeeze them.
1255 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1256 squeeze_lines
> "$actual"
1257 check
"$expected" "$actual" 'ignore space'
1263 # check -noreplacetextplain
1264 start_test
"-noreplacetextplain"
1265 cat >"$expected" <<EOF
1266 To: recipient@example.com
1267 From: sender@example.com
1268 Subject: mhfixmsg replacement of bad text/plain part test
1270 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1273 Content-Type: text/plain; charset="iso-8859-15"
1274 Content-Transfer-Encoding: 7bit
1275 Content-Disposition: inline
1280 Content-Type: text/html; charset="UTF-8"
1281 Content-Disposition: inline
1284 <title>eticket</title>
1287 Yes, the text/plain part really was empty.
1291 ------=_Part_876302--
1294 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1295 check
"$expected" "$actual"
1298 # check removal of extraneous trailing semicolon from header parameter list
1299 start_test
"removal of extraneous trailing semicolon from header parameter list"
1300 cat >"$expected" <<EOF
1301 To: recipient@example.com
1303 From: sender@example.com
1305 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1307 ------- =_aaaaaaaaaa0
1308 Content-Type: text/plain; charset="us-ascii"
1312 ------- =_aaaaaaaaaa0
1313 Content-Type: text/plain; charset="us-ascii";
1315 Content-Description: check folded headers, with and without trailing semicolon
1316 Content-Disposition: attachment;
1321 ------- =_aaaaaaaaaa0--
1324 cat >"`mhpath new`" <<EOF
1325 To: recipient@example.com
1327 From: sender@example.com
1329 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1331 ------- =_aaaaaaaaaa0
1332 Content-Type: text/plain; charset="us-ascii";
1336 ------- =_aaaaaaaaaa0
1337 Content-Type: text/plain; charset="us-ascii";
1339 Content-Description: check folded headers, with and without trailing semicolon
1340 Content-Disposition: attachment;
1345 ------- =_aaaaaaaaaa0--
1347 run_test
'mhfixmsg last -outfile '"$actual" ''
1348 check
"$expected" "$actual"
1351 if [ $can_reformat_texthtml -eq 1 ]; then
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'
1377 start_test
"-rmmproc"
1378 run_test
'mhfixmsg 21 -rmmproc true'
1379 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1380 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1381 failed
=`expr ${failed:-0} + 1`
1386 start_test
"-fixtype"
1387 cat >"$expected" <<EOF
1388 To: recipient@example.com
1389 From: sender@example.com
1390 Subject: mhfixmsg with incorrect Content-Type
1392 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1394 ------- =_aaaaaaaaaa0
1395 Content-Type: text/plain; name="plaintext.txt"
1399 ------- =_aaaaaaaaaa0--
1402 cat >"`mhpath new`" <<EOF
1403 To: recipient@example.com
1404 From: sender@example.com
1405 Subject: mhfixmsg with incorrect Content-Type
1407 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1409 ------- =_aaaaaaaaaa0
1410 Content-Type: application/octet-stream; name="plaintext.txt"
1414 ------- =_aaaaaaaaaa0--
1417 mhfixmsg
-fixtype application
/octet
-stream last
1418 check
"$expected" "`mhpath last`"
1421 # check default -decodetypes
1422 start_test
"default -decodetypes"
1423 cat >$expected <<EOF
1424 To: recipient@example.com
1425 From: sender@example.com
1426 Subject: mhfixmsg decode test 3
1428 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1430 ------- =_aaaaaaaaaa0
1431 Content-Type: text/plain; charset="iso-8859-1"
1432 Content-Disposition: attachment; filename="test1.txt"
1433 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1434 Content-Transfer-Encoding: 7bit
1436 This is the text/plain part.
1438 ------- =_aaaaaaaaaa0
1439 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1440 Content-Disposition: attachment; filename="test2.txt"
1441 Content-Transfer-Encoding: 7bit
1445 This was the text/html part.
1450 ------- =_aaaaaaaaaa0--
1453 cat >"`mhpath new`" <<EOF
1454 To: recipient@example.com
1455 From: sender@example.com
1456 Subject: mhfixmsg decode test 3
1458 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1460 ------- =_aaaaaaaaaa0
1461 Content-Type: text/plain; charset="iso-8859-1"
1462 Content-Disposition: attachment; filename="test1.txt"
1463 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1464 Content-Transfer-Encoding: quoted-printable
1466 This is the text/plain part.
1468 ------- =_aaaaaaaaaa0
1469 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1470 Content-Disposition: attachment; filename="test2.txt"
1471 Content-Transfer-Encoding: base64
1473 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1474 Ym9keT4KPC9odG1sPgo=
1476 ------- =_aaaaaaaaaa0--
1478 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1479 check
"$expected" "$actual"
1482 # check -decodetypes text/plain
1483 start_test
"-decodetypes text/plain"
1484 cat >$expected <<EOF
1485 To: recipient@example.com
1486 From: sender@example.com
1487 Subject: mhfixmsg decode test 4
1489 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1491 ------- =_aaaaaaaaaa0
1492 Content-Type: text/plain; charset="iso-8859-1"
1493 Content-Disposition: attachment; filename="test1.txt"
1494 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1495 Content-Transfer-Encoding: 7bit
1497 This is the text/plain part.
1499 ------- =_aaaaaaaaaa0
1500 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1501 Content-Disposition: attachment; filename="test2.txt"
1502 Content-Transfer-Encoding: base64
1504 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1505 CjwvYm9keT4NCjwvaHRtbD4NCg==
1507 ------- =_aaaaaaaaaa0--
1510 cat >"`mhpath new`" <<EOF
1511 To: recipient@example.com
1512 From: sender@example.com
1513 Subject: mhfixmsg decode test 4
1515 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1517 ------- =_aaaaaaaaaa0
1518 Content-Type: text/plain; charset="iso-8859-1"
1519 Content-Disposition: attachment; filename="test1.txt"
1520 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1521 Content-Transfer-Encoding: quoted-printable
1523 This is the text/plain part.
1525 ------- =_aaaaaaaaaa0
1526 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1527 Content-Disposition: attachment; filename="test2.txt"
1528 Content-Transfer-Encoding: base64
1530 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1531 CjwvYm9keT4NCjwvaHRtbD4NCg==
1533 ------- =_aaaaaaaaaa0--
1535 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1536 check
"$expected" "$actual"
1539 # check -decodetypes attachment/ics
1540 start_test
"-decodetypes attachment/ics"
1541 cat >$expected <<EOF
1542 To: recipient@example.com
1543 From: sender@example.com
1544 Subject: mhfixmsg decode test 5
1546 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1548 ------- =_aaaaaaaaaa0
1549 Content-Type: text/plain; charset="iso-8859-1"
1550 Content-Disposition: attachment; filename="test1.txt"
1551 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1552 Content-Transfer-Encoding: 7bit
1554 This is the text/plain part.
1556 ------- =_aaaaaaaaaa0
1557 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1558 Content-Disposition: attachment; filename="invite.ics"
1559 Content-Transfer-Encoding: 7bit
1565 DTSTAMP:20150101T162400Z
1566 DTSTART:20150105T160000
1567 DTEND:20150105T163000
1568 SUMMARY:4 pm meeting
1572 ------- =_aaaaaaaaaa0--
1575 cat >"`mhpath new`" <<EOF
1576 To: recipient@example.com
1577 From: sender@example.com
1578 Subject: mhfixmsg decode test 5
1580 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1582 ------- =_aaaaaaaaaa0
1583 Content-Type: text/plain; charset="iso-8859-1"
1584 Content-Disposition: attachment; filename="test1.txt"
1585 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1586 Content-Transfer-Encoding: quoted-printable
1591 ------- =_aaaaaaaaaa0
1592 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1593 Content-Disposition: attachment; filename="invite.ics"
1594 Content-Transfer-Encoding: base64
1596 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1597 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1598 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1599 CkVORDpWQ0FMRU5EQVINCg==
1601 ------- =_aaaaaaaaaa0--
1603 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1604 check
"$expected" "$actual"
1607 # check -decodetypes attachment/ics and -nocrlflinebreaks
1608 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1609 cat >$expected <<EOF
1610 To: recipient@example.com
1611 From: sender@example.com
1612 Subject: mhfixmsg decode test 5
1614 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1616 ------- =_aaaaaaaaaa0
1617 Content-Type: text/plain; charset="iso-8859-1"
1618 Content-Disposition: attachment; filename="test1.txt"
1619 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1620 Content-Transfer-Encoding: 7bit
1622 This is the text/plain part.
1624 ------- =_aaaaaaaaaa0
1625 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1626 Content-Disposition: attachment; filename="invite.ics"
1627 Content-Transfer-Encoding: 7bit
1633 DTSTAMP:20150101T162400Z
1634 DTSTART:20150105T160000
1635 DTEND:20150105T163000
1636 SUMMARY:4 pm meeting
1640 ------- =_aaaaaaaaaa0--
1643 cat >"`mhpath new`" <<EOF
1644 To: recipient@example.com
1645 From: sender@example.com
1646 Subject: mhfixmsg decode test 5
1648 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1650 ------- =_aaaaaaaaaa0
1651 Content-Type: text/plain; charset="iso-8859-1"
1652 Content-Disposition: attachment; filename="test1.txt"
1653 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1654 Content-Transfer-Encoding: quoted-printable
1659 ------- =_aaaaaaaaaa0
1660 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1661 Content-Disposition: attachment; filename="invite.ics"
1662 Content-Transfer-Encoding: base64
1664 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1665 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1666 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1667 CkVORDpWQ0FMRU5EQVINCg==
1669 ------- =_aaaaaaaaaa0--
1671 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1672 check
"$expected" "$actual"
1675 # check that input is passed through to output when there's a parse error
1676 # (the charset string is missing its closing quote) with -outfile
1677 start_test
"input is passed through to output when there's a parse error"
1678 cat >"$expected.err" <<EOF
1679 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1681 mhfixmsg: unable to parse message 31
1684 cat >"`mhpath new`" <<EOF
1685 To: recipient@example.com
1686 From: sender@example.com
1687 Subject: mhfixmsg pass through on parse error
1689 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1691 ------- =_aaaaaaaaaa0
1692 Content-Type: text/plain; charset="iso-8859-1
1693 Content-Disposition: attachment; filename="test1.txt"
1694 Content-Transfer-Encoding: quoted-printable
1699 ------- =_aaaaaaaaaa0--
1702 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1704 #### Expected output is identical to the input message.
1705 check
"`mhpath last`" "$actual" 'keep first'
1706 check
"$expected.err" "$actual.err"
1709 # check that input is passed through to output when there's a parse error
1710 # (the charset string is missing its closing quote) with -outfile, and
1711 # input from stdin. Don't check err output, because it contains the name
1712 # of a tmp file. It's similar to that of the previous check.
1713 start_test
"input is passed through to output when there's a parse error"
1715 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1717 #### Expected output is identical to the input message.
1718 check
"`mhpath last`" "$actual" 'keep first'
1721 start_test
"pass through message with relative folder path with parse error"
1722 #### Factor out leading portion of current folder path and make it relative.
1725 run_prog mhfixmsg
+.
/`mhpath | sed "s%^$pwd/%%"` last
-out - >"$actual" 2>/dev
/null
1727 folder
-f +inbox
>/dev
/null
1728 #### Expected output is identical to the input message.
1729 check
"`mhpath last`" "$actual"
1732 start_test
"fix RFC 2047 encoded header parameters"
1733 #### Also, add C-T-E:8bit to the message headers.
1734 cat >"$expected" <<EOF
1735 To: recipient@example.com
1736 From: sender@example.com
1737 Date: Wed, 28 Sep 2016 11:24:28 -0400
1738 Subject: invalid header parameter encoding
1740 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1741 Content-Transfer-Encoding: 8bit
1743 --001a114dd3e8fe9c56053d92f414
1744 Content-Type: text/plain; charset=UTF-8
1748 --001a114dd3e8fe9c56053d92f414
1749 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1750 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1751 Content-Transfer-Encoding: 8bit
1753 This is the first text/plain part, in a subpart. The file name
1756 --001a114dd3e8fe9c56053d92f414--
1759 cat >"`mhpath new`" <<EOF
1760 To: recipient@example.com
1761 From: sender@example.com
1762 Date: Wed, 28 Sep 2016 11:24:28 -0400
1763 Subject: invalid header parameter encoding
1765 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1767 --001a114dd3e8fe9c56053d92f414
1768 Content-Type: text/plain; charset=UTF-8
1772 --001a114dd3e8fe9c56053d92f414
1773 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1774 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1775 Content-Transfer-Encoding: 8bit
1777 This is the first text/plain part, in a subpart. The file name
1780 --001a114dd3e8fe9c56053d92f414--
1782 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1783 check
"$expected" "$actual"
1786 # make sure there are no tmp files left over
1787 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1789 cat >"$expected" <<EOF
1792 check
"$expected" "$actual"