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
56 -decodeheaderfieldbodies utf-8
57 -nodecodeheaderfieldbodies
75 #### Skip nmh intro text.
76 run_prog mhfixmsg
-help 2>&1 | sed '/^$/,$d' >"$actual"
77 check
"$expected" "$actual"
82 case `mhfixmsg -version` in
84 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
85 failed
=`expr ${failed:-0} + 1`;;
89 # check that non-MIME messages aren't modified
91 start_test
"non-MIME messages aren't modified, and -outfile"
92 run_test
'mhfixmsg first -outfile '"$actual" ''
93 check
"`mhpath first`" "$actual" 'keep first'
96 # check that non-MIME messages with no bodies aren't modified
98 start_test
"non-MIME messages with no bodies aren't modified, and -outfile"
99 cat >"`mhpath new`" <<EOF
100 From: Test <test@example.com>
101 To: Some User <user@example.com>
102 Date: Fri, 29 Sep 2006 00:00:00
103 Message-Id: @test.nmh
104 Subject: message with no body
107 run_test
'mhfixmsg last -outfile '"$actual" ''
108 check
"`mhpath last`" "$actual"
112 start_test
"-nofixcte"
113 cat >"`mhpath new`" <<EOF
116 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
117 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
119 Content-Type: MULTIPART/MIXED;
120 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
121 Content-Transfer-Encoding: QUOTED-PRINTABLE
123 This message is in MIME format. The first part should be readable
125 while the remaining parts are likely unreadable without MIME-aware
128 ------=_NextPart_000_0000_00000000.00000000
129 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
130 Content-Transfer-Encoding: 8BIT
132 Some text in swedish.
134 Varf=C3=B6r inte anv=C3=A4nda...
136 ------=_NextPart_000_0000_00000000.00000000--
138 And some text after the last part.
141 cp -p "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12
143 run_test
'mhfixmsg last -nofixcte' ''
144 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/12 'keep first'
147 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
149 start_test
"-fixcte (enabled by default): fixup of erroneous C-T-E in multipart, and -verbose"
150 cat >"$expected" <<EOF
153 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
154 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
156 Content-Type: MULTIPART/MIXED;
157 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
158 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
159 Content-Transfer-Encoding: 8bit
161 This message is in MIME format. The first part should be readable
163 while the remaining parts are likely unreadable without MIME-aware
166 ------=_NextPart_000_0000_00000000.00000000
167 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
168 Content-Transfer-Encoding: 8BIT
170 Some text in swedish.
172 Varf=C3=B6r inte anv=C3=A4nda...
174 ------=_NextPart_000_0000_00000000.00000000--
176 And some text after the last part.
179 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
180 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
181 QUOTED-PRINTABLE with 8 bit"
182 check
"$expected" "$actual" 'keep first'
184 sbackup
="`mhparam sbackup`"
186 # check with no options: checks backup
187 start_test
"with no options: checks backup"
188 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
189 folder last
>/dev
/null
190 run_test
'mhfixmsg' ''
191 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
192 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
193 check
"$MH_TEST_DIR/Mail/inbox/${sbackup}11" "$MH_TEST_DIR"/Mail
/inbox
/11.original
196 # check backup with -file
197 start_test
"backup with -file"
198 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
199 folder last
>/dev
/null
200 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
201 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
202 check
"$MH_TEST_DIR/Mail/inbox/${sbackup}11" "$MH_TEST_DIR"/Mail
/inbox
/11.original
205 # check -file with directory
206 start_test
"-file with directory"
207 run_test
'mhfixmsg -file /tmp' 'mhfixmsg: /tmp is a directory
208 mhfixmsg: unable to parse message from file /tmp'
211 # check -reformat (enabled by default): addition of text/plain part
212 # to solitary text/html part
213 start_test
"-reformat (enabled by default): addition of text/plain part"
214 prepare_space
>"$expected" <<EOF
216 From: sender@example.com
217 To: bonquiqui@example.com
219 Date: Sat, 26 Jan 2013 17:37:53 -0500
220 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
222 ------=_nmh-multipart
223 Content-Type: text/plain; charset="Windows-1252"
224 Content-Transfer-Encoding: 7bit
226 Need to go! Need ... to ... go!
228 ------=_nmh-multipart
229 Content-Type: text/html; charset="Windows-1252"
230 Content-Transfer-Encoding: 7bit
234 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
235 <meta name="Generator" content="Microsoft Exchange Server">
236 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
240 <div>Need to go! Need ... to ... go!</div>
244 ------=_nmh-multipart--
247 cat >"`mhpath new`" <<EOF
249 From: sender@example.com
250 To: bonquiqui@example.com
252 Date: Sat, 26 Jan 2013 17:37:53 -0500
253 Content-Type: text/html; charset="Windows-1252"
254 Content-Transfer-Encoding: quoted-printable
258 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
260 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
261 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
262 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
266 <div>Need to go! Need ... to ... go!</div>
271 if [ $can_reformat_texthtml -eq 1 ]; then
272 printf '%s\n' "mhfixmsg: 12, insert text/plain part
273 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
276 #### lynx inserts multiple blank lines, so squeeze them.
277 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
278 squeeze_lines
>"$actual"
279 check
"$expected" "$actual" 'ignore space'
280 check
"$expected.err" "$actual.err"
286 # check implicit -file with absolute pathname
287 start_test
"implicit -file with absolute pathname"
288 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
291 # check handling of boundary string that appears in message body
292 start_test
"handling of boundary string that appears in message body"
293 prepare_space
>"$expected" <<EOF
295 From: sender@example.com
296 To: bonquiqui@example.com
298 Date: Sat, 26 Jan 2013 17:37:53 -0500
299 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
301 ------=_nmh-multipart-3
302 Content-Type: text/plain; charset="Windows-1252"
303 Content-Transfer-Encoding: 7bit
305 ------=_nmh-multipart
306 ------=_nmh-multipart-1
307 ------=_nmh-multipart-2
309 ------=_nmh-multipart-3
310 Content-Type: text/html; charset="Windows-1252"
311 Content-Transfer-Encoding: 7bit
315 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
316 <meta name="Generator" content="Microsoft Exchange Server">
317 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
320 ------=_nmh-multipart<br>
321 ------=_nmh-multipart-1<br>
322 ------=_nmh-multipart-2<br>
326 ------=_nmh-multipart-3--
329 cat >"`mhpath last`" <<EOF
331 From: sender@example.com
332 To: bonquiqui@example.com
334 Date: Sat, 26 Jan 2013 17:37:53 -0500
335 Content-Type: text/html; charset="Windows-1252"
336 Content-Transfer-Encoding: quoted-printable
340 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
342 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
343 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
344 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
347 ------=3D_nmh-multipart<br>
348 ------=3D_nmh-multipart-1<br>
349 ------=3D_nmh-multipart-2<br>
354 if [ $can_reformat_texthtml -eq 1 ]; then
355 printf '%s\n' "mhfixmsg: 12, insert text/plain part
356 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
359 #### lynx inserts multiple blank lines, so squeeze them.
360 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
361 squeeze_lines
>"$actual"
362 check
"$expected" "$actual" 'ignore space'
363 check
"$expected.err" "$actual.err"
369 # check -nodecodetext
370 start_test
"-nodecodetext"
371 prepare_space
>"$expected" <<EOF
373 From: sender@example.com
374 To: bonquiqui@example.com
376 Date: Sat, 26 Jan 2013 17:37:53 -0500
377 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
379 ------=_nmh-multipart
380 Content-Type: text/plain; charset="Windows-1252"
381 Content-Transfer-Encoding: 7bit
383 Need to go! Need ... to ... go!
385 ------=_nmh-multipart
386 Content-Type: text/html; charset="Windows-1252"
387 Content-Transfer-Encoding: quoted-printable
391 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
393 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
394 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
395 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
399 <div>Need to go! Need ... to ... go!</div>
403 ------=_nmh-multipart--
406 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
408 From: sender@example.com
409 To: bonquiqui@example.com
411 Date: Sat, 26 Jan 2013 17:37:53 -0500
412 Content-Type: text/html; charset="Windows-1252"
413 Content-Transfer-Encoding: quoted-printable
417 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
419 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
420 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
421 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
425 <div>Need to go! Need ... to ... go!</div>
430 if [ $can_reformat_texthtml -eq 1 ]; then
431 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
433 #### lynx inserts multiple blank lines, so squeeze them.
434 run_prog mhfixmsg last
-nodecodetext -outfile - -verbose 2>"$actual.err" | \
435 squeeze_lines
>"$actual"
436 check
"$expected" "$actual" 'ignore space'
437 check
"$expected.err" "$actual.err"
443 # check -decodetext (enabled by default)
444 start_test
"-decodetext (enabled by default)"
445 cat >"$expected" <<EOF
446 To: recipient@example.com
447 From: sender@example.com
448 Subject: mhfixmsg decode test 1
450 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
452 ------- =_aaaaaaaaaa0
453 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
454 Content-Disposition: attachment; filename="test4.txt"
455 Content-Transfer-Encoding: 7bit
457 This is a text/plain part.
459 ------- =_aaaaaaaaaa0--
462 cat >"`mhpath new`" <<EOF
463 To: recipient@example.com
464 From: sender@example.com
465 Subject: mhfixmsg decode test 1
467 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
469 ------- =_aaaaaaaaaa0
470 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
471 Content-Disposition: attachment; filename="test4.txt"
472 Content-Transfer-Encoding: base64
474 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
476 ------- =_aaaaaaaaaa0--
479 run_prog mhfixmsg last
-outfile "$actual"
480 check
"$expected" "$actual"
483 # check -decodetext with more complicated content structure
484 start_test
"-decodetext with more complicated content structure"
486 To: recipient@example.com
487 From: sender@example.com
488 Subject: mhfixmsg decode test 2
490 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
492 This is additional content before the first subpart of the multipart.
494 ------- =_aaaaaaaaaa0
495 Content-Type: multipart/related;
496 type="text/plain"; boundary="subpart__1.1"
499 Content-Type: text/plain; charset="iso-8859-1"
500 Content-Disposition: attachment; filename="test1.txt"
502 This is the first text/plain part, in a subpart.
506 This is additional content after the last subpart of the multipart.
508 ------- =_aaaaaaaaaa0
509 Content-Type: text/plain; charset="iso-8859-1"
510 Content-Disposition: attachment; filename="test2.txt"
511 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
512 Content-Transfer-Encoding: 7bit
514 This is the second text/plain part.
516 ------- =_aaaaaaaaaa0
517 Content-Type: text/plain; charset="iso-8859-1"
518 Content-Disposition: attachment; filename="test3.txt"
520 This is the third text/plain part.
522 ------- =_aaaaaaaaaa0
523 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
524 Content-Disposition: attachment; filename="test4.txt"
525 Content-Transfer-Encoding: 7bit
527 This is the fourth text/plain part.
529 ------- =_aaaaaaaaaa0--
531 This is additional content after the last subpart of the multipart.
534 cat >"`mhpath new`" <<EOF
535 To: recipient@example.com
536 From: sender@example.com
537 Subject: mhfixmsg decode test 2
539 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
541 This is additional content before the first subpart of the multipart.
543 ------- =_aaaaaaaaaa0
544 Content-Type: multipart/related;
545 type="text/plain"; boundary="subpart__1.1"
548 Content-Type: text/plain; charset="iso-8859-1"
549 Content-Disposition: attachment; filename="test1.txt"
551 This is the first text/plain part, in a subpart.
555 This is additional content after the last subpart of the multipart.
557 ------- =_aaaaaaaaaa0
558 Content-Type: text/plain; charset="iso-8859-1"
559 Content-Disposition: attachment; filename="test2.txt"
560 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
561 Content-Transfer-Encoding: quoted-printable
563 This is the second text/plain part.
565 ------- =_aaaaaaaaaa0
566 Content-Type: text/plain; charset="iso-8859-1"
567 Content-Disposition: attachment; filename="test3.txt"
569 This is the third text/plain part.
571 ------- =_aaaaaaaaaa0
572 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
573 Content-Disposition: attachment; filename="test4.txt"
574 Content-Transfer-Encoding: base64
576 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
578 ------- =_aaaaaaaaaa0--
580 This is additional content after the last subpart of the multipart.
582 run_prog mhfixmsg last
-outfile "$actual"
583 check
"$expected" "$actual"
586 # check attempted (default, 8 bit) -decodetext of binary text
587 #### Generated the encoded text below with:
588 #### $ printf '\275\262=\274\000\n' | base64
589 start_test
"attempted (default, 8 bit) -decodetext of binary text"
590 cat >"`mhpath new`" <<EOF
591 To: recipient@example.com
592 From: sender@example.com
593 Subject: mhfixmsg binary decode test
595 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
597 ------- =_aaaaaaaaaa0
598 Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
599 Content-Transfer-Encoding: base64
603 ------- =_aaaaaaaaaa0--
606 cp -p "`mhpath last`" "$expected"
607 run_prog mhfixmsg last
608 check
"`mhpath last`" "$expected" 'keep first'
611 # check for successful decode of a different part with attempted -decodetext
612 # of binary (>998 characters) text
613 start_test
"for successful decode of a different part with attempted -decodetext"
615 To: recipient@example.com
616 From: sender@example.com
617 Subject: mhfixmsg successful decode of text/plain with failed binary decode
619 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
621 ------- =_aaaaaaaaaa0
622 Content-Type: text/plain; charset="iso-8859-1"
623 Content-Transfer-Encoding: 7bit
625 This is a text plain part
627 ------- =_aaaaaaaaaa0
628 Content-Type: text/html; charset="ascii"
629 Content-Transfer-Encoding: base64
630 Content-Disposition: inline
632 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
633 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
634 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
635 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
636 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
637 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
638 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
639 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
640 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
641 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
642 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
643 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
644 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
645 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
646 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
647 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
648 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
649 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
650 ICA8L2JvZHk+PC9odG1sPg==
652 ------- =_aaaaaaaaaa0--
655 cat >"`mhpath new`" <<EOF
656 To: recipient@example.com
657 From: sender@example.com
658 Subject: mhfixmsg successful decode of text/plain with failed binary decode
660 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
662 ------- =_aaaaaaaaaa0
663 Content-Type: text/plain; charset="iso-8859-1"
664 Content-Transfer-Encoding: base64
666 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
668 ------- =_aaaaaaaaaa0
669 Content-Type: text/html; charset="ascii"
670 Content-Transfer-Encoding: base64
671 Content-Disposition: inline
673 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
674 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
675 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
676 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
677 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
678 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
679 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
680 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
681 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
682 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
683 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
684 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
685 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
686 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
687 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
688 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
689 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
690 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
691 ICA8L2JvZHk+PC9odG1sPg==
693 ------- =_aaaaaaaaaa0--
696 run_prog mhfixmsg
-noreformat last
697 check
"`mhpath last`" "$expected" 'keep first'
700 # check for successful decode of a different part with -decodetext of binary
701 # (>998 characters) text
702 start_test
"for successful decode of a different part with -decodetext of binary"
704 To: recipient@example.com
705 From: sender@example.com
706 Subject: mhfixmsg successful decode of text/plain with failed binary decode
708 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
709 Content-Transfer-Encoding: binary
711 ------- =_aaaaaaaaaa0
712 Content-Type: text/plain; charset="iso-8859-1"
713 Content-Transfer-Encoding: 7bit
715 This is a text plain part
717 ------- =_aaaaaaaaaa0
718 Content-Type: text/html; charset="ascii"
719 Content-Transfer-Encoding: binary
720 Content-Disposition: inline
722 <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>
724 ------- =_aaaaaaaaaa0--
727 run_prog mhfixmsg
-noreformat -decodetext binary last
728 check
"`mhpath last`" "$expected"
731 # check -decodetext of binary (containing ASCII NUL) text
732 start_test
"-decodetext of binary (containing ASCII NUL) text"
733 printf "%s\275\262=\274\000%s" "To: recipient@example.com
734 From: sender@example.com
735 Subject: mhfixmsg binary decode test
737 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
738 Content-Transfer-Encoding: binary
740 ------- =_aaaaaaaaaa0
741 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
742 Content-Transfer-Encoding: binary
746 ------- =_aaaaaaaaaa0--
748 mhfixmsg last
-decodetext binary
-outfile "$actual"
749 check
"$expected" "$actual"
752 # check that -reformat succeeds when decode of binary text fails
753 start_test
"-reformat succeeds when decode of binary text fails"
754 prepare_space
>"$expected" <<'EOF'
756 Date: Thu, 11 Apr 2013 02:47:08 -0700
758 From: <sender@example.com>
759 Subject: body requires binary encoding
760 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
762 ------=_nmh-multipart
763 Content-Type: text/plain; charset="ISO-8859-1"
764 Content-Transfer-Encoding: 7bit
769 Vehicle License Fee $1.84
772 ------=_nmh-multipart
773 Content-Type: text/html; charset="ISO-8859-1"
774 Content-Transfer-Encoding: quoted-printable
779 cat >"`mhpath new`" <<'EOF'
781 Content-Type: text/html; charset="ISO-8859-1"
782 Content-Transfer-Encoding: quoted-printable
783 Date: Thu, 11 Apr 2013 02:47:08 -0700
785 From: <sender@example.com>
786 Subject: body requires binary encoding
789 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
790 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
791 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
792 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
793 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
794 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
795 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
796 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
797 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
798 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
799 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
800 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
801 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
802 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
803 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
804 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
805 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
806 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
807 #333333" size=3D"2">$6.00</font></td></tr>
813 if [ $can_reformat_texthtml -eq 1 ]; then
814 #### lynx inserts multiple blank lines, so squeeze them.
815 #### Truncate to avoid comparing the html portion because it can
816 #### get reformatted.
817 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
818 check
"$expected" "$actual" 'ignore space'
820 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
826 # Also checks preservation of attributes after one (charset) that is
828 start_test
"-textcharset"
829 cat >"$expected" <<EOF
830 To: recipient@example.com
831 From: sender@example.com
832 Subject: mhfixmsg textcharset test
834 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
835 Content-Transfer-Encoding: 8bit
837 ------- =_aaaaaaaaaa0
838 Content-Type: text/plain; charset="utf-8"; name="square.txt"
839 Content-Disposition: attachment; filename="square.txt"
840 Content-Transfer-Encoding: 8bit
844 ------- =_aaaaaaaaaa0--
847 #### Generated the encoded text below with:
848 #### $ printf '\275\262=\274\n' | base64
849 cat >"`mhpath new`" <<EOF
850 To: recipient@example.com
851 From: sender@example.com
852 Subject: mhfixmsg textcharset test
854 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
856 ------- =_aaaaaaaaaa0
857 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
858 Content-Disposition: attachment; filename="square.txt"
859 Content-Transfer-Encoding: base64
863 ------- =_aaaaaaaaaa0--
866 if test "$ICONV_ENABLED" -eq 1; then
867 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
868 check
"$expected" "$actual"
870 echo "$0: skipping -textcharset check because nmh was built without iconv"
875 # check -nofixboundary
876 start_test
"-nofixboundary"
877 cat >"$expected" <<EOF
880 cat >"`mhpath new`" <<EOF
881 Date: Fri, 13 May 2011 08:21:12 -0500
882 Content-Type: multipart/alternative;
883 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
884 Content-Transfer-Encoding: 8bit
886 From: <sender@example.com>
887 To: <recipient@example.com>
888 Subject: mhfixmsg bad boundary test
890 This is a multi-part message in MIME format.
892 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
893 Content-Type: text/plain
895 The boundaries of this part don't match the header boundary.
897 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
900 cp -p "`mhpath last`" "`mhpath new`"
902 run_test
'mhfixmsg last -nofixboundary' ''
903 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
906 # check that message is not output when fed through stdin (without -outfile)
907 start_test
"message is not output when fed through stdin"
908 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
909 check
"$expected" "$actual"
910 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
911 "$actual.err" >/dev
/null
; then
914 echo "$0: test failed, output is in $actual.err."
915 failed
=`expr ${failed:-0} + 1`
919 # check fixup of erroneous boundary in multipart (-fixboundary,
920 # enabled by default)
922 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
923 cat >"$expected" <<EOF
924 Date: Fri, 13 May 2011 08:21:12 -0500
925 Content-Type: multipart/alternative;
926 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
927 Content-Transfer-Encoding: 8bit
929 From: <sender@example.com>
930 To: <recipient@example.com>
931 Subject: mhfixmsg bad boundary test
933 This is a multi-part message in MIME format.
935 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
936 Content-Type: text/plain
938 The boundaries of this part don't match the header boundary.
940 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
943 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
944 "mhfixmsg: 18, fix multipart boundary"
945 check
"$expected" "$actual"
948 # check that message is not modified when -fixboundary fails
949 start_test
"message is not modified when -fixboundary fails"
950 cat >"`mhpath new`" <<EOF
951 Date: Fri, 13 May 2011 08:21:12 -0500
952 Content-Type: multipart/alternative;
953 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
954 Content-Transfer-Encoding: 8bit
956 From: <sender@example.com>
957 To: <recipient@example.com>
958 Subject: mhfixmsg bad boundary test
960 This is a multi-part message in MIME format.
962 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
963 Content-Type: text/plain
965 The boundary below doesn't match the header boundary.
968 NextPart_000_1781A1A_01CC1147.81EBA8D4--
971 cp -p "`mhpath last`" "$expected"
972 run_test
"mhfixmsg last -outfile $actual" ''
973 check
"$expected" "$actual"
976 # check that text/plain part is not added to text/html in multipart/related
977 # when it shouldn't be
978 start_test
"text/plain part is not added to text/html in multipart/related when it shouldn't be"
979 cat >"`mhpath new`" <<EOF
981 Date: Tue, 26 Feb 2013 18:07:20 -0600
982 Subject: multipart/related, not /alternative
983 Content-Type: multipart/related;
984 type="text/html"; boundary="----=_Part_90310_101292502.1"
986 ------=_Part_90310_101292502.1
987 Content-Type: text/html; charset="us-ascii"
988 Content-Transfer-Encoding: 7bit
991 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
992 <title>HTML Content</title>
995 This is the real content.
999 ------=_Part_90310_101292502.1
1000 Content-Type: text/plain; charset="us-ascii"
1001 Content-Transfer-Encoding: 7bit
1003 Your email client does not support HTML messages
1005 ------=_Part_90310_101292502.1--
1008 cp -p "`mhpath last`" "$expected"
1010 if [ $can_reformat_texthtml -eq 1 ]; then
1011 #### lynx inserts multiple blank lines, so squeeze them.
1012 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1013 check
"$expected" "$actual" 'ignore space'
1019 # check that text/plain part is added to text/html in multipart/related
1021 start_test
"text/plain part is added to text/html in multipart/related when it should be"
1022 cat >"$expected" <<EOF
1024 Date: Tue, 26 Feb 2013 18:07:20 -0600
1025 Subject: multipart/related, not /alternative
1026 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1028 ------=_Part_90310_101292502.1
1029 Content-Type: text/plain; charset="us-ascii"
1030 Content-Transfer-Encoding: 7bit
1032 This is the real content.
1034 ------=_Part_90310_101292502.1
1035 Content-Type: text/html; charset="us-ascii"
1036 Content-Transfer-Encoding: 7bit
1039 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1040 <title>HTML Content</title>
1043 This is the real content.
1047 ------=_Part_90310_101292502.1--
1050 cat >"`mhpath new`" <<EOF
1052 Date: Tue, 26 Feb 2013 18:07:20 -0600
1053 Subject: multipart/related, not /alternative
1054 Content-Type: multipart/related;
1055 type="text/html"; boundary="----=_Part_90310_101292502.1"
1057 ------=_Part_90310_101292502.1
1058 Content-Type: text/html; charset="us-ascii"
1059 Content-Transfer-Encoding: 7bit
1062 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1063 <title>HTML Content</title>
1066 This is the real content.
1070 ------=_Part_90310_101292502.1--
1073 if [ $can_reformat_texthtml -eq 1 ]; then
1074 #### lynx inserts multiple blank lines, so squeeze them.
1075 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1076 check
"$expected" "$actual" 'ignore space'
1082 # check handling of rfc822 message type
1083 # also, checks -fixboundary
1084 start_test
"handling of rfc822 message type"
1085 cat >"$expected" <<EOF
1086 From: Test <test@example.com>
1087 To: Some User <user@example.com>
1088 Date: Fri, 29 Sep 2006 00:00:00
1089 Message-Id: @test.nmh
1090 Subject: message with message/rfc822 attachment
1092 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1094 and some garbage before the attachment
1096 ------- =_aaaaaaaaaa0
1097 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1098 Content-Description: 1552
1099 Content-Disposition: attachment; filename="1552"
1101 From: Test <test@example.com>
1102 To: <another_user@example.com>
1103 Date: Thu, 28 Sep 2006 00:00:00
1104 Message-Id: @test.nmh
1105 Subject: message/rfc822 attachment
1107 This is an RFC-822 message.
1109 ------- =_aaaaaaaaaa0--
1111 and some garbage at the end
1114 cat >"`mhpath new`" <<EOF
1115 From: Test <test@example.com>
1116 To: Some User <user@example.com>
1117 Date: Fri, 29 Sep 2006 00:00:00
1118 Message-Id: @test.nmh
1119 Subject: message with message/rfc822 attachment
1121 Content-Type: multipart/mixed; boundary="----- =badboundary"
1123 and some garbage before the attachment
1125 ------- =_aaaaaaaaaa0
1126 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1127 Content-Description: 1552
1128 Content-Disposition: attachment; filename="1552"
1130 From: Test <test@example.com>
1131 To: <another_user@example.com>
1132 Date: Thu, 28 Sep 2006 00:00:00
1133 Message-Id: @test.nmh
1134 Subject: message/rfc822 attachment
1136 This is an RFC-822 message.
1138 ------- =_aaaaaaaaaa0--
1140 and some garbage at the end
1143 run_test
'mhfixmsg last -outfile '"$actual" ''
1144 check
"$expected" "$actual"
1147 # check not stripping of CRs from ASCII text context (default)
1148 start_test
"not stripping of CRs from ASCII text context (default)"
1149 cat >"$expected" <<EOF
1151 From: sender@example.com
1152 To: recipient@example.com
1153 Subject: message with CR's
1154 Date: Mon, 29 Apr 2013 11:51:45 -0400
1156 There are two CR-LF pairs at the end of this sentence.
1160 cat >"`mhpath new`" <<'EOF'
1162 From: sender@example.com
1163 To: recipient@example.com
1164 Subject: message with CR's
1165 Date: Mon, 29 Apr 2013 11:51:45 -0400
1167 There are two CR-LF pairs at the end of this sentence.
1171 run_prog mhfixmsg last
-outfile "$actual"
1172 check
"$expected" "$actual"
1175 # check stripping of CRs from ASCII text context
1176 start_test
"stripping of CRs from ASCII text context"
1177 cat >"$expected" <<EOF
1179 From: sender@example.com
1180 To: recipient@example.com
1181 Subject: message with CR's
1182 Date: Mon, 29 Apr 2013 11:51:45 -0400
1184 There were two CR-LF pairs at the end of this sentence.
1188 cat >"`mhpath new`" <<'EOF'
1190 From: sender@example.com
1191 To: recipient@example.com
1192 Subject: message with CR's
1193 Date: Mon, 29 Apr 2013 11:51:45 -0400
1195 There were two CR-LF pairs at the end of this sentence.
1199 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1200 check
"$expected" "$actual"
1203 # check -replacetextplain
1204 start_test
"-replacetextplain"
1205 prepare_space
>"$expected" <<EOF
1206 To: recipient@example.com
1207 From: sender@example.com
1208 Subject: mhfixmsg replacement of bad text/plain part test
1210 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1213 Content-Type: text/plain; charset="UTF-8"
1214 Content-Transfer-Encoding: 7bit
1216 Yes, the text/plain part really was empty.
1219 Content-Type: text/html; charset="UTF-8"
1220 Content-Disposition: inline
1223 <title>eticket</title>
1226 Yes, the text/plain part really was empty.
1230 ------=_Part_876302--
1233 cat >"`mhpath new`" <<'EOF'
1234 To: recipient@example.com
1235 From: sender@example.com
1236 Subject: mhfixmsg replacement of bad text/plain part test
1238 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1241 Content-Type: text/plain; charset="iso-8859-15"
1242 Content-Transfer-Encoding: 7bit
1243 Content-Disposition: inline
1248 Content-Type: text/html; charset="UTF-8"
1249 Content-Disposition: inline
1252 <title>eticket</title>
1255 Yes, the text/plain part really was empty.
1259 ------=_Part_876302--
1262 if [ $can_reformat_texthtml -eq 1 ]; then
1263 #### lynx inserts multiple blank lines, so squeeze them.
1264 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1265 squeeze_lines
> "$actual"
1266 check
"$expected" "$actual" 'ignore space'
1272 # check -noreplacetextplain
1273 start_test
"-noreplacetextplain"
1274 cat >"$expected" <<EOF
1275 To: recipient@example.com
1276 From: sender@example.com
1277 Subject: mhfixmsg replacement of bad text/plain part test
1279 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1282 Content-Type: text/plain; charset="iso-8859-15"
1283 Content-Transfer-Encoding: 7bit
1284 Content-Disposition: inline
1289 Content-Type: text/html; charset="UTF-8"
1290 Content-Disposition: inline
1293 <title>eticket</title>
1296 Yes, the text/plain part really was empty.
1300 ------=_Part_876302--
1303 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1304 check
"$expected" "$actual"
1307 # check removal of extraneous trailing semicolon from header parameter list
1308 start_test
"removal of extraneous trailing semicolon from header parameter list"
1309 cat >"$expected" <<EOF
1310 To: recipient@example.com
1312 From: sender@example.com
1314 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1316 ------- =_aaaaaaaaaa0
1317 Content-Type: text/plain; charset="us-ascii"
1321 ------- =_aaaaaaaaaa0
1322 Content-Type: text/plain; charset="us-ascii";
1324 Content-Description: check folded headers, with and without trailing semicolon
1325 Content-Disposition: attachment;
1330 ------- =_aaaaaaaaaa0--
1333 cat >"`mhpath new`" <<EOF
1334 To: recipient@example.com
1336 From: sender@example.com
1338 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1340 ------- =_aaaaaaaaaa0
1341 Content-Type: text/plain; charset="us-ascii";
1345 ------- =_aaaaaaaaaa0
1346 Content-Type: text/plain; charset="us-ascii";
1348 Content-Description: check folded headers, with and without trailing semicolon
1349 Content-Disposition: attachment;
1354 ------- =_aaaaaaaaaa0--
1356 run_test
'mhfixmsg last -outfile '"$actual" ''
1357 check
"$expected" "$actual"
1360 if [ $can_reformat_texthtml -eq 1 ]; then
1362 start_test
"rmmproc"
1363 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1366 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1367 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1368 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1370 run_test
'mhfixmsg 16' ''
1371 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1372 "${MH_TEST_DIR}/Mail/inbox/16.original"
1376 start_test
"-normmproc"
1377 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1379 run_test
'mhfixmsg 21 -normmproc'
1380 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1381 "${MH_TEST_DIR}/Mail/inbox/${sbackup}21" 'keep first'
1386 start_test
"-rmmproc"
1387 run_test
'mhfixmsg 21 -rmmproc true'
1388 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1389 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1390 failed
=`expr ${failed:-0} + 1`
1395 start_test
"-fixtype"
1396 cat >"$expected" <<EOF
1397 To: recipient@example.com
1398 From: sender@example.com
1399 Subject: mhfixmsg with incorrect Content-Type
1401 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1403 ------- =_aaaaaaaaaa0
1404 Content-Type: text/plain; name="plaintext.txt"
1408 ------- =_aaaaaaaaaa0--
1411 cat >"`mhpath new`" <<EOF
1412 To: recipient@example.com
1413 From: sender@example.com
1414 Subject: mhfixmsg with incorrect Content-Type
1416 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1418 ------- =_aaaaaaaaaa0
1419 Content-Type: application/octet-stream; name="plaintext.txt"
1423 ------- =_aaaaaaaaaa0--
1426 mhfixmsg
-fixtype application
/octet
-stream last
1427 check
"$expected" "`mhpath last`"
1430 # check default -decodetypes
1431 start_test
"default -decodetypes"
1432 cat >$expected <<EOF
1433 To: recipient@example.com
1434 From: sender@example.com
1435 Subject: mhfixmsg decode test 3
1437 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1439 ------- =_aaaaaaaaaa0
1440 Content-Type: text/plain; charset="iso-8859-1"
1441 Content-Disposition: attachment; filename="test1.txt"
1442 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1443 Content-Transfer-Encoding: 7bit
1445 This is the text/plain part.
1447 ------- =_aaaaaaaaaa0
1448 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1449 Content-Disposition: attachment; filename="test2.txt"
1450 Content-Transfer-Encoding: 7bit
1454 This was the text/html part.
1459 ------- =_aaaaaaaaaa0--
1462 cat >"`mhpath new`" <<EOF
1463 To: recipient@example.com
1464 From: sender@example.com
1465 Subject: mhfixmsg decode test 3
1467 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1469 ------- =_aaaaaaaaaa0
1470 Content-Type: text/plain; charset="iso-8859-1"
1471 Content-Disposition: attachment; filename="test1.txt"
1472 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1473 Content-Transfer-Encoding: quoted-printable
1475 This is the text/plain part.
1477 ------- =_aaaaaaaaaa0
1478 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1479 Content-Disposition: attachment; filename="test2.txt"
1480 Content-Transfer-Encoding: base64
1482 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1483 Ym9keT4KPC9odG1sPgo=
1485 ------- =_aaaaaaaaaa0--
1487 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1488 check
"$expected" "$actual"
1491 # check -decodetypes text/plain
1492 start_test
"-decodetypes text/plain"
1493 cat >$expected <<EOF
1494 To: recipient@example.com
1495 From: sender@example.com
1496 Subject: mhfixmsg decode test 4
1498 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1500 ------- =_aaaaaaaaaa0
1501 Content-Type: text/plain; charset="iso-8859-1"
1502 Content-Disposition: attachment; filename="test1.txt"
1503 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1504 Content-Transfer-Encoding: 7bit
1506 This is the text/plain part.
1508 ------- =_aaaaaaaaaa0
1509 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1510 Content-Disposition: attachment; filename="test2.txt"
1511 Content-Transfer-Encoding: base64
1513 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1514 CjwvYm9keT4NCjwvaHRtbD4NCg==
1516 ------- =_aaaaaaaaaa0--
1519 cat >"`mhpath new`" <<EOF
1520 To: recipient@example.com
1521 From: sender@example.com
1522 Subject: mhfixmsg decode test 4
1524 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1526 ------- =_aaaaaaaaaa0
1527 Content-Type: text/plain; charset="iso-8859-1"
1528 Content-Disposition: attachment; filename="test1.txt"
1529 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1530 Content-Transfer-Encoding: quoted-printable
1532 This is the text/plain part.
1534 ------- =_aaaaaaaaaa0
1535 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1536 Content-Disposition: attachment; filename="test2.txt"
1537 Content-Transfer-Encoding: base64
1539 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1540 CjwvYm9keT4NCjwvaHRtbD4NCg==
1542 ------- =_aaaaaaaaaa0--
1544 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1545 check
"$expected" "$actual"
1548 # check -decodetypes attachment/ics
1549 start_test
"-decodetypes attachment/ics"
1550 cat >$expected <<EOF
1551 To: recipient@example.com
1552 From: sender@example.com
1553 Subject: mhfixmsg decode test 5
1555 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1557 ------- =_aaaaaaaaaa0
1558 Content-Type: text/plain; charset="iso-8859-1"
1559 Content-Disposition: attachment; filename="test1.txt"
1560 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1561 Content-Transfer-Encoding: 7bit
1563 This is the text/plain part.
1565 ------- =_aaaaaaaaaa0
1566 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1567 Content-Disposition: attachment; filename="invite.ics"
1568 Content-Transfer-Encoding: 7bit
1574 DTSTAMP:20150101T162400Z
1575 DTSTART:20150105T160000
1576 DTEND:20150105T163000
1577 SUMMARY:4 pm meeting
1581 ------- =_aaaaaaaaaa0--
1584 cat >"`mhpath new`" <<EOF
1585 To: recipient@example.com
1586 From: sender@example.com
1587 Subject: mhfixmsg decode test 5
1589 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1591 ------- =_aaaaaaaaaa0
1592 Content-Type: text/plain; charset="iso-8859-1"
1593 Content-Disposition: attachment; filename="test1.txt"
1594 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1595 Content-Transfer-Encoding: quoted-printable
1600 ------- =_aaaaaaaaaa0
1601 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1602 Content-Disposition: attachment; filename="invite.ics"
1603 Content-Transfer-Encoding: base64
1605 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1606 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1607 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1608 CkVORDpWQ0FMRU5EQVINCg==
1610 ------- =_aaaaaaaaaa0--
1612 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1613 check
"$expected" "$actual"
1616 # check -decodetypes attachment/ics and -nocrlflinebreaks
1617 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1618 cat >$expected <<EOF
1619 To: recipient@example.com
1620 From: sender@example.com
1621 Subject: mhfixmsg decode test 5
1623 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1625 ------- =_aaaaaaaaaa0
1626 Content-Type: text/plain; charset="iso-8859-1"
1627 Content-Disposition: attachment; filename="test1.txt"
1628 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1629 Content-Transfer-Encoding: 7bit
1631 This is the text/plain part.
1633 ------- =_aaaaaaaaaa0
1634 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1635 Content-Disposition: attachment; filename="invite.ics"
1636 Content-Transfer-Encoding: 7bit
1642 DTSTAMP:20150101T162400Z
1643 DTSTART:20150105T160000
1644 DTEND:20150105T163000
1645 SUMMARY:4 pm meeting
1649 ------- =_aaaaaaaaaa0--
1652 cat >"`mhpath new`" <<EOF
1653 To: recipient@example.com
1654 From: sender@example.com
1655 Subject: mhfixmsg decode test 5
1657 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1659 ------- =_aaaaaaaaaa0
1660 Content-Type: text/plain; charset="iso-8859-1"
1661 Content-Disposition: attachment; filename="test1.txt"
1662 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1663 Content-Transfer-Encoding: quoted-printable
1668 ------- =_aaaaaaaaaa0
1669 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1670 Content-Disposition: attachment; filename="invite.ics"
1671 Content-Transfer-Encoding: base64
1673 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1674 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1675 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1676 CkVORDpWQ0FMRU5EQVINCg==
1678 ------- =_aaaaaaaaaa0--
1680 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1681 check
"$expected" "$actual"
1684 # check that input is passed through to output when there's a parse error
1685 # (the charset string is missing its closing quote) with -outfile
1686 start_test
"input is passed through to output when there's a parse error"
1687 cat >"$expected.err" <<EOF
1688 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1690 mhfixmsg: unable to parse message 31
1693 cat >"`mhpath new`" <<EOF
1694 To: recipient@example.com
1695 From: sender@example.com
1696 Subject: mhfixmsg pass through on parse error
1698 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1700 ------- =_aaaaaaaaaa0
1701 Content-Type: text/plain; charset="iso-8859-1
1702 Content-Disposition: attachment; filename="test1.txt"
1703 Content-Transfer-Encoding: quoted-printable
1708 ------- =_aaaaaaaaaa0--
1711 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1713 #### Expected output is identical to the input message.
1714 check
"`mhpath last`" "$actual" 'keep first'
1715 check
"$expected.err" "$actual.err"
1718 # check that input is passed through to output when there's a parse error
1719 # (the charset string is missing its closing quote) with -outfile, and
1720 # input from stdin. Don't check err output, because it contains the name
1721 # of a tmp file. It's similar to that of the previous check.
1722 start_test
"input is passed through to output when there's a parse error"
1724 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1726 #### Expected output is identical to the input message.
1727 check
"`mhpath last`" "$actual" 'keep first'
1730 start_test
"pass through message with relative folder path with parse error"
1731 #### Factor out leading portion of current folder path and make it relative.
1734 run_prog mhfixmsg
+.
/`mhpath | sed "s%^$pwd/%%"` last
-out - >"$actual" 2>/dev
/null
1736 folder
-f +inbox
>/dev
/null
1737 #### Expected output is identical to the input message.
1738 check
"`mhpath last`" "$actual"
1741 start_test
"fix RFC 2047 encoded header parameters"
1742 #### Also, add C-T-E:8bit to the message headers.
1743 cat >"$expected" <<EOF
1744 To: recipient@example.com
1745 From: sender@example.com
1746 Date: Wed, 28 Sep 2016 11:24:28 -0400
1747 Subject: invalid header parameter encoding
1749 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1750 Content-Transfer-Encoding: 8bit
1752 --001a114dd3e8fe9c56053d92f414
1753 Content-Type: text/plain; charset=UTF-8
1757 --001a114dd3e8fe9c56053d92f414
1758 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1759 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1760 Content-Transfer-Encoding: 8bit
1762 This is the first text/plain part, in a subpart. The file name
1765 --001a114dd3e8fe9c56053d92f414--
1768 cat >"`mhpath new`" <<EOF
1769 To: recipient@example.com
1770 From: sender@example.com
1771 Date: Wed, 28 Sep 2016 11:24:28 -0400
1772 Subject: invalid header parameter encoding
1774 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1776 --001a114dd3e8fe9c56053d92f414
1777 Content-Type: text/plain; charset=UTF-8
1781 --001a114dd3e8fe9c56053d92f414
1782 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1783 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1784 Content-Transfer-Encoding: 8bit
1786 This is the first text/plain part, in a subpart. The file name
1789 --001a114dd3e8fe9c56053d92f414--
1791 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1792 check
"$expected" "$actual"
1795 start_test
"-nodecodeheaderfieldbodies"
1796 cat >"`mhpath new`" <<EOF
1797 To: recipient@example.com
1798 From: sender@example.com
1799 Date: Wed, 28 Sep 2016 11:24:28 -0400
1800 Subject: =?utf-8?B?dGhpcyBTdWJqZWN0IHdhcyBVVEYtOCBlbmNvZGVk?=
1802 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1803 Content-Transfer-Encoding: 8bit
1805 --001a114dd3e8fe9c56053d92f414
1806 Content-Type: text/plain; charset=UTF-8
1810 --001a114dd3e8fe9c56053d92f414
1811 Content-Type: text/plain; charset=UTF-8; name="test.txt"
1812 Content-Disposition: attachment; filename="test.txt"
1813 Content-Transfer-Encoding: 8bit
1815 This is the first text/plain part, in a subpart. The file name
1818 --001a114dd3e8fe9c56053d92f414--
1820 run_prog mhfixmsg
-file - -outfile - -decodeheaderfieldbodies utf
-8 \
1821 -nodecodeheaderfieldbodies <`mhpath last` >"$actual" 2>/dev
/null
1822 check
`mhpath last` "$actual" 'keep first'
1825 start_test
"test decoding of UTF-8 header value"
1826 cat >"$expected" <<EOF
1827 To: recipient@example.com
1828 From: sender@example.com
1829 Date: Wed, 28 Sep 2016 11:24:28 -0400
1830 Subject: this Subject was UTF-8 encoded
1832 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1833 Content-Transfer-Encoding: 8bit
1835 --001a114dd3e8fe9c56053d92f414
1836 Content-Type: text/plain; charset=UTF-8
1840 --001a114dd3e8fe9c56053d92f414
1841 Content-Type: text/plain; charset=UTF-8; name="test.txt"
1842 Content-Disposition: attachment; filename="test.txt"
1843 Content-Transfer-Encoding: 8bit
1845 This is the first text/plain part, in a subpart. The file name
1848 --001a114dd3e8fe9c56053d92f414--
1851 run_prog mhfixmsg
-file - -outfile - -decodeheaderfieldbodies utf
-8 \
1852 <`mhpath last` >"$actual" 2>/dev
/null
1853 check
"$expected" "$actual"
1856 # make sure there are no tmp files left over
1857 find "$MH_TEST_DIR/Mail" -name '*mhfix*' -print \
1859 cat >"$expected" <<EOF
1862 check
"$expected" "$actual"