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 -file with directory
203 start_test
"-file with directory"
204 run_test
'mhfixmsg -file /tmp' 'mhfixmsg: /tmp is a directory
205 mhfixmsg: unable to parse message from file /tmp'
208 # check -reformat (enabled by default): addition of text/plain part
209 # to solitary text/html part
210 start_test
"-reformat (enabled by default): addition of text/plain part"
211 prepare_space
>"$expected" <<EOF
213 From: sender@example.com
214 To: bonquiqui@example.com
216 Date: Sat, 26 Jan 2013 17:37:53 -0500
217 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
219 ------=_nmh-multipart
220 Content-Type: text/plain; charset="Windows-1252"
221 Content-Transfer-Encoding: 7bit
223 Need to go! Need ... to ... go!
225 ------=_nmh-multipart
226 Content-Type: text/html; charset="Windows-1252"
227 Content-Transfer-Encoding: 7bit
231 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
232 <meta name="Generator" content="Microsoft Exchange Server">
233 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
237 <div>Need to go! Need ... to ... go!</div>
241 ------=_nmh-multipart--
244 cat >"`mhpath new`" <<EOF
246 From: sender@example.com
247 To: bonquiqui@example.com
249 Date: Sat, 26 Jan 2013 17:37:53 -0500
250 Content-Type: text/html; charset="Windows-1252"
251 Content-Transfer-Encoding: quoted-printable
255 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
257 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
258 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
259 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
263 <div>Need to go! Need ... to ... go!</div>
268 if [ $can_reformat_texthtml -eq 1 ]; then
269 printf '%s\n' "mhfixmsg: 12, insert text/plain part
270 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
273 #### lynx inserts multiple blank lines, so squeeze them.
274 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
275 squeeze_lines
>"$actual"
276 check
"$expected" "$actual" 'ignore space'
277 check
"$expected.err" "$actual.err"
283 # check implicit -file with absolute pathname
284 start_test
"implicit -file with absolute pathname"
285 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
288 # check handling of boundary string that appears in message body
289 start_test
"handling of boundary string that appears in message body"
290 prepare_space
>"$expected" <<EOF
292 From: sender@example.com
293 To: bonquiqui@example.com
295 Date: Sat, 26 Jan 2013 17:37:53 -0500
296 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
298 ------=_nmh-multipart-3
299 Content-Type: text/plain; charset="Windows-1252"
300 Content-Transfer-Encoding: 7bit
302 ------=_nmh-multipart
303 ------=_nmh-multipart-1
304 ------=_nmh-multipart-2
306 ------=_nmh-multipart-3
307 Content-Type: text/html; charset="Windows-1252"
308 Content-Transfer-Encoding: 7bit
312 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
313 <meta name="Generator" content="Microsoft Exchange Server">
314 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
317 ------=_nmh-multipart<br>
318 ------=_nmh-multipart-1<br>
319 ------=_nmh-multipart-2<br>
323 ------=_nmh-multipart-3--
326 cat >"`mhpath last`" <<EOF
328 From: sender@example.com
329 To: bonquiqui@example.com
331 Date: Sat, 26 Jan 2013 17:37:53 -0500
332 Content-Type: text/html; charset="Windows-1252"
333 Content-Transfer-Encoding: quoted-printable
337 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
339 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
340 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
341 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
344 ------=3D_nmh-multipart<br>
345 ------=3D_nmh-multipart-1<br>
346 ------=3D_nmh-multipart-2<br>
351 if [ $can_reformat_texthtml -eq 1 ]; then
352 printf '%s\n' "mhfixmsg: 12, insert text/plain part
353 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
356 #### lynx inserts multiple blank lines, so squeeze them.
357 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
358 squeeze_lines
>"$actual"
359 check
"$expected" "$actual" 'ignore space'
360 check
"$expected.err" "$actual.err"
367 start_test
"-nodecode"
368 prepare_space
>"$expected" <<EOF
370 From: sender@example.com
371 To: bonquiqui@example.com
373 Date: Sat, 26 Jan 2013 17:37:53 -0500
374 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
376 ------=_nmh-multipart
377 Content-Type: text/plain; charset="Windows-1252"
378 Content-Transfer-Encoding: 7bit
380 Need to go! Need ... to ... go!
382 ------=_nmh-multipart
383 Content-Type: text/html; charset="Windows-1252"
384 Content-Transfer-Encoding: quoted-printable
388 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
390 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
391 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
392 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
396 <div>Need to go! Need ... to ... go!</div>
400 ------=_nmh-multipart--
403 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
405 From: sender@example.com
406 To: bonquiqui@example.com
408 Date: Sat, 26 Jan 2013 17:37:53 -0500
409 Content-Type: text/html; charset="Windows-1252"
410 Content-Transfer-Encoding: quoted-printable
414 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
416 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
417 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
418 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
422 <div>Need to go! Need ... to ... go!</div>
427 if [ $can_reformat_texthtml -eq 1 ]; then
428 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
430 #### lynx inserts multiple blank lines, so squeeze them.
431 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
432 squeeze_lines
>"$actual"
433 check
"$expected" "$actual" 'ignore space'
434 check
"$expected.err" "$actual.err"
440 # check -decodetext (enabled by default)
441 start_test
"-decodetext (enabled by default)"
442 cat >"$expected" <<EOF
443 To: recipient@example.com
444 From: sender@example.com
445 Subject: mhfixmsg decode test 1
447 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
449 ------- =_aaaaaaaaaa0
450 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
451 Content-Disposition: attachment; filename="test4.txt"
452 Content-Transfer-Encoding: 7bit
454 This is a text/plain part.
456 ------- =_aaaaaaaaaa0--
459 cat >"`mhpath new`" <<EOF
460 To: recipient@example.com
461 From: sender@example.com
462 Subject: mhfixmsg decode test 1
464 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
466 ------- =_aaaaaaaaaa0
467 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
468 Content-Disposition: attachment; filename="test4.txt"
469 Content-Transfer-Encoding: base64
471 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
473 ------- =_aaaaaaaaaa0--
476 run_prog mhfixmsg last
-outfile "$actual"
477 check
"$expected" "$actual"
480 # check -decodetext with more complicated content structure
481 start_test
"-decodetext with more complicated content structure"
483 To: recipient@example.com
484 From: sender@example.com
485 Subject: mhfixmsg decode test 2
487 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
489 This is additional content before the first subpart of the multipart.
491 ------- =_aaaaaaaaaa0
492 Content-Type: multipart/related;
493 type="text/plain"; boundary="subpart__1.1"
496 Content-Type: text/plain; charset="iso-8859-1"
497 Content-Disposition: attachment; filename="test1.txt"
499 This is the first text/plain part, in a subpart.
503 This is additional content after the last subpart of the multipart.
505 ------- =_aaaaaaaaaa0
506 Content-Type: text/plain; charset="iso-8859-1"
507 Content-Disposition: attachment; filename="test2.txt"
508 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
509 Content-Transfer-Encoding: 7bit
511 This is the second text/plain part.
513 ------- =_aaaaaaaaaa0
514 Content-Type: text/plain; charset="iso-8859-1"
515 Content-Disposition: attachment; filename="test3.txt"
517 This is the third text/plain part.
519 ------- =_aaaaaaaaaa0
520 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
521 Content-Disposition: attachment; filename="test4.txt"
522 Content-Transfer-Encoding: 7bit
524 This is the fourth text/plain part.
526 ------- =_aaaaaaaaaa0--
528 This is additional content after the last subpart of the multipart.
531 cat >"`mhpath new`" <<EOF
532 To: recipient@example.com
533 From: sender@example.com
534 Subject: mhfixmsg decode test 2
536 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
538 This is additional content before the first subpart of the multipart.
540 ------- =_aaaaaaaaaa0
541 Content-Type: multipart/related;
542 type="text/plain"; boundary="subpart__1.1"
545 Content-Type: text/plain; charset="iso-8859-1"
546 Content-Disposition: attachment; filename="test1.txt"
548 This is the first text/plain part, in a subpart.
552 This is additional content after the last subpart of the multipart.
554 ------- =_aaaaaaaaaa0
555 Content-Type: text/plain; charset="iso-8859-1"
556 Content-Disposition: attachment; filename="test2.txt"
557 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
558 Content-Transfer-Encoding: quoted-printable
560 This is the second text/plain part.
562 ------- =_aaaaaaaaaa0
563 Content-Type: text/plain; charset="iso-8859-1"
564 Content-Disposition: attachment; filename="test3.txt"
566 This is the third text/plain part.
568 ------- =_aaaaaaaaaa0
569 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
570 Content-Disposition: attachment; filename="test4.txt"
571 Content-Transfer-Encoding: base64
573 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
575 ------- =_aaaaaaaaaa0--
577 This is additional content after the last subpart of the multipart.
579 run_prog mhfixmsg last
-outfile "$actual"
580 check
"$expected" "$actual"
583 # check attempted (default, 8 bit) -decodetext of binary text
584 #### Generated the encoded text below with:
585 #### $ printf '\275\262=\274\000\n' | base64
586 start_test
"attempted (default, 8 bit) -decodetext of binary text"
587 cat >"`mhpath new`" <<EOF
588 To: recipient@example.com
589 From: sender@example.com
590 Subject: mhfixmsg binary decode test
592 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
594 ------- =_aaaaaaaaaa0
595 Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
596 Content-Transfer-Encoding: base64
600 ------- =_aaaaaaaaaa0--
603 cp -p "`mhpath last`" "$expected"
604 run_prog mhfixmsg last
605 check
"`mhpath last`" "$expected" 'keep first'
608 # check for successful decode of a different part with attempted -decodetext
609 # of binary (>998 characters) text
610 start_test
"for successful decode of a different part with attempted -decodetext"
612 To: recipient@example.com
613 From: sender@example.com
614 Subject: mhfixmsg successful decode of text/plain with failed binary decode
616 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
618 ------- =_aaaaaaaaaa0
619 Content-Type: text/plain; charset="iso-8859-1"
620 Content-Transfer-Encoding: 7bit
622 This is a text plain part
624 ------- =_aaaaaaaaaa0
625 Content-Type: text/html; charset="ascii"
626 Content-Transfer-Encoding: base64
627 Content-Disposition: inline
629 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
630 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
631 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
632 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
633 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
634 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
635 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
636 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
637 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
638 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
639 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
640 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
641 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
642 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
643 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
644 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
645 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
646 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
647 ICA8L2JvZHk+PC9odG1sPg==
649 ------- =_aaaaaaaaaa0--
652 cat >"`mhpath new`" <<EOF
653 To: recipient@example.com
654 From: sender@example.com
655 Subject: mhfixmsg successful decode of text/plain with failed binary decode
657 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
659 ------- =_aaaaaaaaaa0
660 Content-Type: text/plain; charset="iso-8859-1"
661 Content-Transfer-Encoding: base64
663 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
665 ------- =_aaaaaaaaaa0
666 Content-Type: text/html; charset="ascii"
667 Content-Transfer-Encoding: base64
668 Content-Disposition: inline
670 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
671 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
672 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
673 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
674 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
675 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
676 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
677 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
678 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
679 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
680 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
681 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
682 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
683 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
684 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
685 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
686 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
687 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
688 ICA8L2JvZHk+PC9odG1sPg==
690 ------- =_aaaaaaaaaa0--
693 run_prog mhfixmsg
-noreformat last
694 check
"`mhpath last`" "$expected" 'keep first'
697 # check for successful decode of a different part with -decodetext of binary
698 # (>998 characters) text
699 start_test
"for successful decode of a different part with -decodetext of binary"
701 To: recipient@example.com
702 From: sender@example.com
703 Subject: mhfixmsg successful decode of text/plain with failed binary decode
705 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
706 Content-Transfer-Encoding: binary
708 ------- =_aaaaaaaaaa0
709 Content-Type: text/plain; charset="iso-8859-1"
710 Content-Transfer-Encoding: 7bit
712 This is a text plain part
714 ------- =_aaaaaaaaaa0
715 Content-Type: text/html; charset="ascii"
716 Content-Transfer-Encoding: binary
717 Content-Disposition: inline
719 <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>
721 ------- =_aaaaaaaaaa0--
724 run_prog mhfixmsg
-noreformat -decodetext binary last
725 check
"`mhpath last`" "$expected"
728 # check -decodetext of binary (containing ASCII NUL) text
729 start_test
"-decodetext of binary (containing ASCII NUL) text"
730 printf "%s\275\262=\274\000%s" "To: recipient@example.com
731 From: sender@example.com
732 Subject: mhfixmsg binary decode test
734 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
735 Content-Transfer-Encoding: binary
737 ------- =_aaaaaaaaaa0
738 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
739 Content-Transfer-Encoding: binary
743 ------- =_aaaaaaaaaa0--
745 mhfixmsg last
-decodetext binary
-outfile "$actual"
746 check
"$expected" "$actual"
749 # check that -reformat succeeds when decode of binary text fails
750 start_test
"-reformat succeeds when decode of binary text fails"
751 prepare_space
>"$expected" <<'EOF'
753 Date: Thu, 11 Apr 2013 02:47:08 -0700
755 From: <sender@example.com>
756 Subject: body requires binary encoding
757 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
759 ------=_nmh-multipart
760 Content-Type: text/plain; charset="ISO-8859-1"
761 Content-Transfer-Encoding: 7bit
766 Vehicle License Fee $1.84
769 ------=_nmh-multipart
770 Content-Type: text/html; charset="ISO-8859-1"
771 Content-Transfer-Encoding: quoted-printable
776 cat >"`mhpath new`" <<'EOF'
778 Content-Type: text/html; charset="ISO-8859-1"
779 Content-Transfer-Encoding: quoted-printable
780 Date: Thu, 11 Apr 2013 02:47:08 -0700
782 From: <sender@example.com>
783 Subject: body requires binary encoding
786 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
787 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
788 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
789 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
790 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
791 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
792 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
793 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
794 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
795 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
796 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
797 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
798 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
799 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
800 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
801 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
802 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
803 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
804 #333333" size=3D"2">$6.00</font></td></tr>
810 if [ $can_reformat_texthtml -eq 1 ]; then
811 #### lynx inserts multiple blank lines, so squeeze them.
812 #### Truncate to avoid comparing the html portion because it can
813 #### get reformatted.
814 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
815 check
"$expected" "$actual" 'ignore space'
817 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
823 # Also checks preservation of attributes after one (charset) that is
825 start_test
"-textcharset"
826 cat >"$expected" <<EOF
827 To: recipient@example.com
828 From: sender@example.com
829 Subject: mhfixmsg textcharset test
831 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
832 Content-Transfer-Encoding: 8bit
834 ------- =_aaaaaaaaaa0
835 Content-Type: text/plain; charset="utf-8"; name="square.txt"
836 Content-Disposition: attachment; filename="square.txt"
837 Content-Transfer-Encoding: 8bit
841 ------- =_aaaaaaaaaa0--
844 #### Generated the encoded text below with:
845 #### $ printf '\275\262=\274\n' | base64
846 cat >"`mhpath new`" <<EOF
847 To: recipient@example.com
848 From: sender@example.com
849 Subject: mhfixmsg textcharset test
851 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
853 ------- =_aaaaaaaaaa0
854 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
855 Content-Disposition: attachment; filename="square.txt"
856 Content-Transfer-Encoding: base64
860 ------- =_aaaaaaaaaa0--
863 if test "$ICONV_ENABLED" -eq 1; then
864 run_prog mhfixmsg last
-textcharset utf
-8 -outfile "$actual" 2>&1
865 check
"$expected" "$actual"
867 echo "$0: skipping -textcharset check because nmh was built without iconv"
872 # check -nofixboundary
873 start_test
"-nofixboundary"
874 cat >"$expected" <<EOF
877 cat >"`mhpath new`" <<EOF
878 Date: Fri, 13 May 2011 08:21:12 -0500
879 Content-Type: multipart/alternative;
880 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
881 Content-Transfer-Encoding: 8bit
883 From: <sender@example.com>
884 To: <recipient@example.com>
885 Subject: mhfixmsg bad boundary test
887 This is a multi-part message in MIME format.
889 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
890 Content-Type: text/plain
892 The boundaries of this part don't match the header boundary.
894 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
897 cp -p "`mhpath last`" "`mhpath new`"
899 run_test
'mhfixmsg last -nofixboundary' ''
900 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
903 # check that message is not output when fed through stdin (without -outfile)
904 start_test
"message is not output when fed through stdin"
905 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
906 check
"$expected" "$actual"
907 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
908 "$actual.err" >/dev
/null
; then
911 echo "$0: test failed, output is in $actual.err."
912 failed
=`expr ${failed:-0} + 1`
916 # check fixup of erroneous boundary in multipart (-fixboundary,
917 # enabled by default)
919 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
920 cat >"$expected" <<EOF
921 Date: Fri, 13 May 2011 08:21:12 -0500
922 Content-Type: multipart/alternative;
923 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
924 Content-Transfer-Encoding: 8bit
926 From: <sender@example.com>
927 To: <recipient@example.com>
928 Subject: mhfixmsg bad boundary test
930 This is a multi-part message in MIME format.
932 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
933 Content-Type: text/plain
935 The boundaries of this part don't match the header boundary.
937 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
940 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
941 "mhfixmsg: 18, fix multipart boundary"
942 check
"$expected" "$actual"
945 # check that message is not modified when -fixboundary fails
946 start_test
"message is not modified when -fixboundary fails"
947 cat >"`mhpath new`" <<EOF
948 Date: Fri, 13 May 2011 08:21:12 -0500
949 Content-Type: multipart/alternative;
950 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
951 Content-Transfer-Encoding: 8bit
953 From: <sender@example.com>
954 To: <recipient@example.com>
955 Subject: mhfixmsg bad boundary test
957 This is a multi-part message in MIME format.
959 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
960 Content-Type: text/plain
962 The boundary below doesn't match the header boundary.
965 NextPart_000_1781A1A_01CC1147.81EBA8D4--
968 cp -p "`mhpath last`" "$expected"
969 run_test
"mhfixmsg last -outfile $actual" ''
970 check
"$expected" "$actual"
973 # check that text/plain part is not added to text/html in multipart/related
974 # when it shouldn't be
975 start_test
"text/plain part is not added to text/html in multipart/related when it shouldn't be"
976 cat >"`mhpath new`" <<EOF
978 Date: Tue, 26 Feb 2013 18:07:20 -0600
979 Subject: multipart/related, not /alternative
980 Content-Type: multipart/related;
981 type="text/html"; boundary="----=_Part_90310_101292502.1"
983 ------=_Part_90310_101292502.1
984 Content-Type: text/html; charset="us-ascii"
985 Content-Transfer-Encoding: 7bit
988 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
989 <title>HTML Content</title>
992 This is the real content.
996 ------=_Part_90310_101292502.1
997 Content-Type: text/plain; charset="us-ascii"
998 Content-Transfer-Encoding: 7bit
1000 Your email client does not support HTML messages
1002 ------=_Part_90310_101292502.1--
1005 cp -p "`mhpath last`" "$expected"
1007 if [ $can_reformat_texthtml -eq 1 ]; then
1008 #### lynx inserts multiple blank lines, so squeeze them.
1009 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1010 check
"$expected" "$actual" 'ignore space'
1016 # check that text/plain part is added to text/html in multipart/related
1018 start_test
"text/plain part is added to text/html in multipart/related when it should be"
1019 cat >"$expected" <<EOF
1021 Date: Tue, 26 Feb 2013 18:07:20 -0600
1022 Subject: multipart/related, not /alternative
1023 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1025 ------=_Part_90310_101292502.1
1026 Content-Type: text/plain; charset="us-ascii"
1027 Content-Transfer-Encoding: 7bit
1029 This is the real content.
1031 ------=_Part_90310_101292502.1
1032 Content-Type: text/html; charset="us-ascii"
1033 Content-Transfer-Encoding: 7bit
1036 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1037 <title>HTML Content</title>
1040 This is the real content.
1044 ------=_Part_90310_101292502.1--
1047 cat >"`mhpath new`" <<EOF
1049 Date: Tue, 26 Feb 2013 18:07:20 -0600
1050 Subject: multipart/related, not /alternative
1051 Content-Type: multipart/related;
1052 type="text/html"; boundary="----=_Part_90310_101292502.1"
1054 ------=_Part_90310_101292502.1
1055 Content-Type: text/html; charset="us-ascii"
1056 Content-Transfer-Encoding: 7bit
1059 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1060 <title>HTML Content</title>
1063 This is the real content.
1067 ------=_Part_90310_101292502.1--
1070 if [ $can_reformat_texthtml -eq 1 ]; then
1071 #### lynx inserts multiple blank lines, so squeeze them.
1072 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1073 check
"$expected" "$actual" 'ignore space'
1079 # check handling of rfc822 message type
1080 # also, checks -fixboundary
1081 start_test
"handling of rfc822 message type"
1082 cat >"$expected" <<EOF
1083 From: Test <test@example.com>
1084 To: Some User <user@example.com>
1085 Date: Fri, 29 Sep 2006 00:00:00
1086 Message-Id: @test.nmh
1087 Subject: message with message/rfc822 attachment
1089 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1091 and some garbage before the attachment
1093 ------- =_aaaaaaaaaa0
1094 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1095 Content-Description: 1552
1096 Content-Disposition: attachment; filename="1552"
1098 From: Test <test@example.com>
1099 To: <another_user@example.com>
1100 Date: Thu, 28 Sep 2006 00:00:00
1101 Message-Id: @test.nmh
1102 Subject: message/rfc822 attachment
1104 This is an RFC-822 message.
1106 ------- =_aaaaaaaaaa0--
1108 and some garbage at the end
1111 cat >"`mhpath new`" <<EOF
1112 From: Test <test@example.com>
1113 To: Some User <user@example.com>
1114 Date: Fri, 29 Sep 2006 00:00:00
1115 Message-Id: @test.nmh
1116 Subject: message with message/rfc822 attachment
1118 Content-Type: multipart/mixed; boundary="----- =badboundary"
1120 and some garbage before the attachment
1122 ------- =_aaaaaaaaaa0
1123 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1124 Content-Description: 1552
1125 Content-Disposition: attachment; filename="1552"
1127 From: Test <test@example.com>
1128 To: <another_user@example.com>
1129 Date: Thu, 28 Sep 2006 00:00:00
1130 Message-Id: @test.nmh
1131 Subject: message/rfc822 attachment
1133 This is an RFC-822 message.
1135 ------- =_aaaaaaaaaa0--
1137 and some garbage at the end
1140 run_test
'mhfixmsg last -outfile '"$actual" ''
1141 check
"$expected" "$actual"
1144 # check not stripping of CRs from ASCII text context (default)
1145 start_test
"not stripping of CRs from ASCII text context (default)"
1146 cat >"$expected" <<EOF
1148 From: sender@example.com
1149 To: recipient@example.com
1150 Subject: message with CR's
1151 Date: Mon, 29 Apr 2013 11:51:45 -0400
1153 There are two CR-LF pairs at the end of this sentence.
1157 cat >"`mhpath new`" <<'EOF'
1159 From: sender@example.com
1160 To: recipient@example.com
1161 Subject: message with CR's
1162 Date: Mon, 29 Apr 2013 11:51:45 -0400
1164 There are two CR-LF pairs at the end of this sentence.
1168 run_prog mhfixmsg last
-outfile "$actual"
1169 check
"$expected" "$actual"
1172 # check stripping of CRs from ASCII text context
1173 start_test
"stripping of CRs from ASCII text context"
1174 cat >"$expected" <<EOF
1176 From: sender@example.com
1177 To: recipient@example.com
1178 Subject: message with CR's
1179 Date: Mon, 29 Apr 2013 11:51:45 -0400
1181 There were two CR-LF pairs at the end of this sentence.
1185 cat >"`mhpath new`" <<'EOF'
1187 From: sender@example.com
1188 To: recipient@example.com
1189 Subject: message with CR's
1190 Date: Mon, 29 Apr 2013 11:51:45 -0400
1192 There were two CR-LF pairs at the end of this sentence.
1196 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1197 check
"$expected" "$actual"
1200 # check -replacetextplain
1201 start_test
"-replacetextplain"
1202 prepare_space
>"$expected" <<EOF
1203 To: recipient@example.com
1204 From: sender@example.com
1205 Subject: mhfixmsg replacement of bad text/plain part test
1207 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1210 Content-Type: text/plain; charset="UTF-8"
1211 Content-Transfer-Encoding: 7bit
1213 Yes, the text/plain part really was empty.
1216 Content-Type: text/html; charset="UTF-8"
1217 Content-Disposition: inline
1220 <title>eticket</title>
1223 Yes, the text/plain part really was empty.
1227 ------=_Part_876302--
1230 cat >"`mhpath new`" <<'EOF'
1231 To: recipient@example.com
1232 From: sender@example.com
1233 Subject: mhfixmsg replacement of bad text/plain part test
1235 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1238 Content-Type: text/plain; charset="iso-8859-15"
1239 Content-Transfer-Encoding: 7bit
1240 Content-Disposition: inline
1245 Content-Type: text/html; charset="UTF-8"
1246 Content-Disposition: inline
1249 <title>eticket</title>
1252 Yes, the text/plain part really was empty.
1256 ------=_Part_876302--
1259 if [ $can_reformat_texthtml -eq 1 ]; then
1260 #### lynx inserts multiple blank lines, so squeeze them.
1261 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1262 squeeze_lines
> "$actual"
1263 check
"$expected" "$actual" 'ignore space'
1269 # check -noreplacetextplain
1270 start_test
"-noreplacetextplain"
1271 cat >"$expected" <<EOF
1272 To: recipient@example.com
1273 From: sender@example.com
1274 Subject: mhfixmsg replacement of bad text/plain part test
1276 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1279 Content-Type: text/plain; charset="iso-8859-15"
1280 Content-Transfer-Encoding: 7bit
1281 Content-Disposition: inline
1286 Content-Type: text/html; charset="UTF-8"
1287 Content-Disposition: inline
1290 <title>eticket</title>
1293 Yes, the text/plain part really was empty.
1297 ------=_Part_876302--
1300 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1301 check
"$expected" "$actual"
1304 # check removal of extraneous trailing semicolon from header parameter list
1305 start_test
"removal of extraneous trailing semicolon from header parameter list"
1306 cat >"$expected" <<EOF
1307 To: recipient@example.com
1309 From: sender@example.com
1311 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1313 ------- =_aaaaaaaaaa0
1314 Content-Type: text/plain; charset="us-ascii"
1318 ------- =_aaaaaaaaaa0
1319 Content-Type: text/plain; charset="us-ascii";
1321 Content-Description: check folded headers, with and without trailing semicolon
1322 Content-Disposition: attachment;
1327 ------- =_aaaaaaaaaa0--
1330 cat >"`mhpath new`" <<EOF
1331 To: recipient@example.com
1333 From: sender@example.com
1335 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1337 ------- =_aaaaaaaaaa0
1338 Content-Type: text/plain; charset="us-ascii";
1342 ------- =_aaaaaaaaaa0
1343 Content-Type: text/plain; charset="us-ascii";
1345 Content-Description: check folded headers, with and without trailing semicolon
1346 Content-Disposition: attachment;
1351 ------- =_aaaaaaaaaa0--
1353 run_test
'mhfixmsg last -outfile '"$actual" ''
1354 check
"$expected" "$actual"
1357 if [ $can_reformat_texthtml -eq 1 ]; then
1359 start_test
"rmmproc"
1360 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1363 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1364 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1365 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1367 run_test
'mhfixmsg 16' ''
1368 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1369 "${MH_TEST_DIR}/Mail/inbox/16.original"
1373 start_test
"-normmproc"
1374 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1376 run_test
'mhfixmsg 21 -normmproc'
1377 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1378 "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
1383 start_test
"-rmmproc"
1384 run_test
'mhfixmsg 21 -rmmproc true'
1385 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1386 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1387 failed
=`expr ${failed:-0} + 1`
1392 start_test
"-fixtype"
1393 cat >"$expected" <<EOF
1394 To: recipient@example.com
1395 From: sender@example.com
1396 Subject: mhfixmsg with incorrect Content-Type
1398 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1400 ------- =_aaaaaaaaaa0
1401 Content-Type: text/plain; name="plaintext.txt"
1405 ------- =_aaaaaaaaaa0--
1408 cat >"`mhpath new`" <<EOF
1409 To: recipient@example.com
1410 From: sender@example.com
1411 Subject: mhfixmsg with incorrect Content-Type
1413 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1415 ------- =_aaaaaaaaaa0
1416 Content-Type: application/octet-stream; name="plaintext.txt"
1420 ------- =_aaaaaaaaaa0--
1423 mhfixmsg
-fixtype application
/octet
-stream last
1424 check
"$expected" "`mhpath last`"
1427 # check default -decodetypes
1428 start_test
"default -decodetypes"
1429 cat >$expected <<EOF
1430 To: recipient@example.com
1431 From: sender@example.com
1432 Subject: mhfixmsg decode test 3
1434 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1436 ------- =_aaaaaaaaaa0
1437 Content-Type: text/plain; charset="iso-8859-1"
1438 Content-Disposition: attachment; filename="test1.txt"
1439 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1440 Content-Transfer-Encoding: 7bit
1442 This is the text/plain part.
1444 ------- =_aaaaaaaaaa0
1445 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1446 Content-Disposition: attachment; filename="test2.txt"
1447 Content-Transfer-Encoding: 7bit
1451 This was the text/html part.
1456 ------- =_aaaaaaaaaa0--
1459 cat >"`mhpath new`" <<EOF
1460 To: recipient@example.com
1461 From: sender@example.com
1462 Subject: mhfixmsg decode test 3
1464 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1466 ------- =_aaaaaaaaaa0
1467 Content-Type: text/plain; charset="iso-8859-1"
1468 Content-Disposition: attachment; filename="test1.txt"
1469 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1470 Content-Transfer-Encoding: quoted-printable
1472 This is the text/plain part.
1474 ------- =_aaaaaaaaaa0
1475 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1476 Content-Disposition: attachment; filename="test2.txt"
1477 Content-Transfer-Encoding: base64
1479 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1480 Ym9keT4KPC9odG1sPgo=
1482 ------- =_aaaaaaaaaa0--
1484 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1485 check
"$expected" "$actual"
1488 # check -decodetypes text/plain
1489 start_test
"-decodetypes text/plain"
1490 cat >$expected <<EOF
1491 To: recipient@example.com
1492 From: sender@example.com
1493 Subject: mhfixmsg decode test 4
1495 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1497 ------- =_aaaaaaaaaa0
1498 Content-Type: text/plain; charset="iso-8859-1"
1499 Content-Disposition: attachment; filename="test1.txt"
1500 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1501 Content-Transfer-Encoding: 7bit
1503 This is the text/plain part.
1505 ------- =_aaaaaaaaaa0
1506 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1507 Content-Disposition: attachment; filename="test2.txt"
1508 Content-Transfer-Encoding: base64
1510 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1511 CjwvYm9keT4NCjwvaHRtbD4NCg==
1513 ------- =_aaaaaaaaaa0--
1516 cat >"`mhpath new`" <<EOF
1517 To: recipient@example.com
1518 From: sender@example.com
1519 Subject: mhfixmsg decode test 4
1521 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1523 ------- =_aaaaaaaaaa0
1524 Content-Type: text/plain; charset="iso-8859-1"
1525 Content-Disposition: attachment; filename="test1.txt"
1526 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1527 Content-Transfer-Encoding: quoted-printable
1529 This is the text/plain part.
1531 ------- =_aaaaaaaaaa0
1532 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1533 Content-Disposition: attachment; filename="test2.txt"
1534 Content-Transfer-Encoding: base64
1536 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1537 CjwvYm9keT4NCjwvaHRtbD4NCg==
1539 ------- =_aaaaaaaaaa0--
1541 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1542 check
"$expected" "$actual"
1545 # check -decodetypes attachment/ics
1546 start_test
"-decodetypes attachment/ics"
1547 cat >$expected <<EOF
1548 To: recipient@example.com
1549 From: sender@example.com
1550 Subject: mhfixmsg decode test 5
1552 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1554 ------- =_aaaaaaaaaa0
1555 Content-Type: text/plain; charset="iso-8859-1"
1556 Content-Disposition: attachment; filename="test1.txt"
1557 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1558 Content-Transfer-Encoding: 7bit
1560 This is the text/plain part.
1562 ------- =_aaaaaaaaaa0
1563 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1564 Content-Disposition: attachment; filename="invite.ics"
1565 Content-Transfer-Encoding: 7bit
1571 DTSTAMP:20150101T162400Z
1572 DTSTART:20150105T160000
1573 DTEND:20150105T163000
1574 SUMMARY:4 pm meeting
1578 ------- =_aaaaaaaaaa0--
1581 cat >"`mhpath new`" <<EOF
1582 To: recipient@example.com
1583 From: sender@example.com
1584 Subject: mhfixmsg decode test 5
1586 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1588 ------- =_aaaaaaaaaa0
1589 Content-Type: text/plain; charset="iso-8859-1"
1590 Content-Disposition: attachment; filename="test1.txt"
1591 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1592 Content-Transfer-Encoding: quoted-printable
1597 ------- =_aaaaaaaaaa0
1598 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1599 Content-Disposition: attachment; filename="invite.ics"
1600 Content-Transfer-Encoding: base64
1602 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1603 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1604 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1605 CkVORDpWQ0FMRU5EQVINCg==
1607 ------- =_aaaaaaaaaa0--
1609 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1610 check
"$expected" "$actual"
1613 # check -decodetypes attachment/ics and -nocrlflinebreaks
1614 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1615 cat >$expected <<EOF
1616 To: recipient@example.com
1617 From: sender@example.com
1618 Subject: mhfixmsg decode test 5
1620 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1622 ------- =_aaaaaaaaaa0
1623 Content-Type: text/plain; charset="iso-8859-1"
1624 Content-Disposition: attachment; filename="test1.txt"
1625 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1626 Content-Transfer-Encoding: 7bit
1628 This is the text/plain part.
1630 ------- =_aaaaaaaaaa0
1631 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1632 Content-Disposition: attachment; filename="invite.ics"
1633 Content-Transfer-Encoding: 7bit
1639 DTSTAMP:20150101T162400Z
1640 DTSTART:20150105T160000
1641 DTEND:20150105T163000
1642 SUMMARY:4 pm meeting
1646 ------- =_aaaaaaaaaa0--
1649 cat >"`mhpath new`" <<EOF
1650 To: recipient@example.com
1651 From: sender@example.com
1652 Subject: mhfixmsg decode test 5
1654 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1656 ------- =_aaaaaaaaaa0
1657 Content-Type: text/plain; charset="iso-8859-1"
1658 Content-Disposition: attachment; filename="test1.txt"
1659 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1660 Content-Transfer-Encoding: quoted-printable
1665 ------- =_aaaaaaaaaa0
1666 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1667 Content-Disposition: attachment; filename="invite.ics"
1668 Content-Transfer-Encoding: base64
1670 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1671 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1672 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1673 CkVORDpWQ0FMRU5EQVINCg==
1675 ------- =_aaaaaaaaaa0--
1677 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1678 check
"$expected" "$actual"
1681 # check that input is passed through to output when there's a parse error
1682 # (the charset string is missing its closing quote) with -outfile
1683 start_test
"input is passed through to output when there's a parse error"
1684 cat >"$expected.err" <<EOF
1685 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1687 mhfixmsg: unable to parse message 31
1690 cat >"`mhpath new`" <<EOF
1691 To: recipient@example.com
1692 From: sender@example.com
1693 Subject: mhfixmsg pass through on parse error
1695 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1697 ------- =_aaaaaaaaaa0
1698 Content-Type: text/plain; charset="iso-8859-1
1699 Content-Disposition: attachment; filename="test1.txt"
1700 Content-Transfer-Encoding: quoted-printable
1705 ------- =_aaaaaaaaaa0--
1708 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1710 #### Expected output is identical to the input message.
1711 check
"`mhpath last`" "$actual" 'keep first'
1712 check
"$expected.err" "$actual.err"
1715 # check that input is passed through to output when there's a parse error
1716 # (the charset string is missing its closing quote) with -outfile, and
1717 # input from stdin. Don't check err output, because it contains the name
1718 # of a tmp file. It's similar to that of the previous check.
1719 start_test
"input is passed through to output when there's a parse error"
1721 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1723 #### Expected output is identical to the input message.
1724 check
"`mhpath last`" "$actual" 'keep first'
1727 start_test
"pass through message with relative folder path with parse error"
1728 #### Factor out leading portion of current folder path and make it relative.
1731 run_prog mhfixmsg
+.
/`mhpath | sed "s%^$pwd/%%"` last
-out - >"$actual" 2>/dev
/null
1733 folder
-f +inbox
>/dev
/null
1734 #### Expected output is identical to the input message.
1735 check
"`mhpath last`" "$actual"
1738 start_test
"fix RFC 2047 encoded header parameters"
1739 #### Also, add C-T-E:8bit to the message headers.
1740 cat >"$expected" <<EOF
1741 To: recipient@example.com
1742 From: sender@example.com
1743 Date: Wed, 28 Sep 2016 11:24:28 -0400
1744 Subject: invalid header parameter encoding
1746 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1747 Content-Transfer-Encoding: 8bit
1749 --001a114dd3e8fe9c56053d92f414
1750 Content-Type: text/plain; charset=UTF-8
1754 --001a114dd3e8fe9c56053d92f414
1755 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1756 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1757 Content-Transfer-Encoding: 8bit
1759 This is the first text/plain part, in a subpart. The file name
1762 --001a114dd3e8fe9c56053d92f414--
1765 cat >"`mhpath new`" <<EOF
1766 To: recipient@example.com
1767 From: sender@example.com
1768 Date: Wed, 28 Sep 2016 11:24:28 -0400
1769 Subject: invalid header parameter encoding
1771 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1773 --001a114dd3e8fe9c56053d92f414
1774 Content-Type: text/plain; charset=UTF-8
1778 --001a114dd3e8fe9c56053d92f414
1779 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1780 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1781 Content-Transfer-Encoding: 8bit
1783 This is the first text/plain part, in a subpart. The file name
1786 --001a114dd3e8fe9c56053d92f414--
1788 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1789 check
"$expected" "$actual"
1792 # make sure there are no tmp files left over
1793 find "$MH_TEST_DIR/Mail" \
( -name 'mhfix*' -o -name ',mhfix*' \
) -print \
1795 cat >"$expected" <<EOF
1798 check
"$expected" "$actual"