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'
182 sbackup
="`mhparam sbackup`"
184 # check with no options: checks backup
185 start_test
"with no options: checks backup"
186 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
187 folder last
>/dev
/null
188 run_test
'mhfixmsg' ''
189 check
"$expected" "$MH_TEST_DIR"/Mail
/inbox
/11 'keep first'
190 cp "$MH_TEST_DIR"/Mail
/inbox
/11.original
"$MH_TEST_DIR"/Mail
/inbox
/11
191 check
"$MH_TEST_DIR/Mail/inbox/${sbackup}11" "$MH_TEST_DIR"/Mail
/inbox
/11.original
194 # check backup with -file
195 start_test
"backup with -file"
196 cp "$MH_TEST_DIR"/Mail
/inbox
/11 "$MH_TEST_DIR"/Mail
/inbox
/11.original
197 folder last
>/dev
/null
198 run_test
'mhfixmsg -file '"$MH_TEST_DIR"/Mail
/inbox
/11 ''
199 check
"$MH_TEST_DIR"/Mail
/inbox
/11 "$expected" 'keep first'
200 check
"$MH_TEST_DIR/Mail/inbox/${sbackup}11" "$MH_TEST_DIR"/Mail
/inbox
/11.original
203 # check -file with directory
204 start_test
"-file with directory"
205 run_test
'mhfixmsg -file /tmp' 'mhfixmsg: /tmp is a directory
206 mhfixmsg: unable to parse message from file /tmp'
209 # check -reformat (enabled by default): addition of text/plain part
210 # to solitary text/html part
211 start_test
"-reformat (enabled by default): addition of text/plain part"
212 prepare_space
>"$expected" <<EOF
214 From: sender@example.com
215 To: bonquiqui@example.com
217 Date: Sat, 26 Jan 2013 17:37:53 -0500
218 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
220 ------=_nmh-multipart
221 Content-Type: text/plain; charset="Windows-1252"
222 Content-Transfer-Encoding: 7bit
224 Need to go! Need ... to ... go!
226 ------=_nmh-multipart
227 Content-Type: text/html; charset="Windows-1252"
228 Content-Transfer-Encoding: 7bit
232 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
233 <meta name="Generator" content="Microsoft Exchange Server">
234 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
238 <div>Need to go! Need ... to ... go!</div>
242 ------=_nmh-multipart--
245 cat >"`mhpath new`" <<EOF
247 From: sender@example.com
248 To: bonquiqui@example.com
250 Date: Sat, 26 Jan 2013 17:37:53 -0500
251 Content-Type: text/html; charset="Windows-1252"
252 Content-Transfer-Encoding: quoted-printable
256 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
258 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
259 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
260 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
264 <div>Need to go! Need ... to ... go!</div>
269 if [ $can_reformat_texthtml -eq 1 ]; then
270 printf '%s\n' "mhfixmsg: 12, insert text/plain part
271 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
274 #### lynx inserts multiple blank lines, so squeeze them.
275 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
276 squeeze_lines
>"$actual"
277 check
"$expected" "$actual" 'ignore space'
278 check
"$expected.err" "$actual.err"
284 # check implicit -file with absolute pathname
285 start_test
"implicit -file with absolute pathname"
286 run_test
"mhfixmsg `mhpath last` -outfile /dev/null" ''
289 # check handling of boundary string that appears in message body
290 start_test
"handling of boundary string that appears in message body"
291 prepare_space
>"$expected" <<EOF
293 From: sender@example.com
294 To: bonquiqui@example.com
296 Date: Sat, 26 Jan 2013 17:37:53 -0500
297 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
299 ------=_nmh-multipart-3
300 Content-Type: text/plain; charset="Windows-1252"
301 Content-Transfer-Encoding: 7bit
303 ------=_nmh-multipart
304 ------=_nmh-multipart-1
305 ------=_nmh-multipart-2
307 ------=_nmh-multipart-3
308 Content-Type: text/html; charset="Windows-1252"
309 Content-Transfer-Encoding: 7bit
313 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
314 <meta name="Generator" content="Microsoft Exchange Server">
315 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
318 ------=_nmh-multipart<br>
319 ------=_nmh-multipart-1<br>
320 ------=_nmh-multipart-2<br>
324 ------=_nmh-multipart-3--
327 cat >"`mhpath last`" <<EOF
329 From: sender@example.com
330 To: bonquiqui@example.com
332 Date: Sat, 26 Jan 2013 17:37:53 -0500
333 Content-Type: text/html; charset="Windows-1252"
334 Content-Transfer-Encoding: quoted-printable
338 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
340 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
341 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
342 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
345 ------=3D_nmh-multipart<br>
346 ------=3D_nmh-multipart-1<br>
347 ------=3D_nmh-multipart-2<br>
352 if [ $can_reformat_texthtml -eq 1 ]; then
353 printf '%s\n' "mhfixmsg: 12, insert text/plain part
354 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
357 #### lynx inserts multiple blank lines, so squeeze them.
358 run_prog mhfixmsg last
-outfile - -verbose 2>"$actual.err" | \
359 squeeze_lines
>"$actual"
360 check
"$expected" "$actual" 'ignore space'
361 check
"$expected.err" "$actual.err"
368 start_test
"-nodecode"
369 prepare_space
>"$expected" <<EOF
371 From: sender@example.com
372 To: bonquiqui@example.com
374 Date: Sat, 26 Jan 2013 17:37:53 -0500
375 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
377 ------=_nmh-multipart
378 Content-Type: text/plain; charset="Windows-1252"
379 Content-Transfer-Encoding: 7bit
381 Need to go! Need ... to ... go!
383 ------=_nmh-multipart
384 Content-Type: text/html; charset="Windows-1252"
385 Content-Transfer-Encoding: quoted-printable
389 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
391 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
392 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
393 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
397 <div>Need to go! Need ... to ... go!</div>
401 ------=_nmh-multipart--
404 cat >"$MH_TEST_DIR"/Mail
/inbox
/12 <<EOF
406 From: sender@example.com
407 To: bonquiqui@example.com
409 Date: Sat, 26 Jan 2013 17:37:53 -0500
410 Content-Type: text/html; charset="Windows-1252"
411 Content-Transfer-Encoding: quoted-printable
415 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
417 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
418 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
419 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
423 <div>Need to go! Need ... to ... go!</div>
428 if [ $can_reformat_texthtml -eq 1 ]; then
429 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
431 #### lynx inserts multiple blank lines, so squeeze them.
432 run_prog mhfixmsg last
-nodecode -outfile - -verbose 2>"$actual.err" | \
433 squeeze_lines
>"$actual"
434 check
"$expected" "$actual" 'ignore space'
435 check
"$expected.err" "$actual.err"
441 # check -decodetext (enabled by default)
442 start_test
"-decodetext (enabled by default)"
443 cat >"$expected" <<EOF
444 To: recipient@example.com
445 From: sender@example.com
446 Subject: mhfixmsg decode test 1
448 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
450 ------- =_aaaaaaaaaa0
451 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
452 Content-Disposition: attachment; filename="test4.txt"
453 Content-Transfer-Encoding: 7bit
455 This is a text/plain part.
457 ------- =_aaaaaaaaaa0--
460 cat >"`mhpath new`" <<EOF
461 To: recipient@example.com
462 From: sender@example.com
463 Subject: mhfixmsg decode test 1
465 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
467 ------- =_aaaaaaaaaa0
468 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
469 Content-Disposition: attachment; filename="test4.txt"
470 Content-Transfer-Encoding: base64
472 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
474 ------- =_aaaaaaaaaa0--
477 run_prog mhfixmsg last
-outfile "$actual"
478 check
"$expected" "$actual"
481 # check -decodetext with more complicated content structure
482 start_test
"-decodetext with more complicated content structure"
484 To: recipient@example.com
485 From: sender@example.com
486 Subject: mhfixmsg decode test 2
488 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
490 This is additional content before the first subpart of the multipart.
492 ------- =_aaaaaaaaaa0
493 Content-Type: multipart/related;
494 type="text/plain"; boundary="subpart__1.1"
497 Content-Type: text/plain; charset="iso-8859-1"
498 Content-Disposition: attachment; filename="test1.txt"
500 This is the first text/plain part, in a subpart.
504 This is additional content after the last subpart of the multipart.
506 ------- =_aaaaaaaaaa0
507 Content-Type: text/plain; charset="iso-8859-1"
508 Content-Disposition: attachment; filename="test2.txt"
509 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
510 Content-Transfer-Encoding: 7bit
512 This is the second text/plain part.
514 ------- =_aaaaaaaaaa0
515 Content-Type: text/plain; charset="iso-8859-1"
516 Content-Disposition: attachment; filename="test3.txt"
518 This is the third text/plain part.
520 ------- =_aaaaaaaaaa0
521 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
522 Content-Disposition: attachment; filename="test4.txt"
523 Content-Transfer-Encoding: 7bit
525 This is the fourth text/plain part.
527 ------- =_aaaaaaaaaa0--
529 This is additional content after the last subpart of the multipart.
532 cat >"`mhpath new`" <<EOF
533 To: recipient@example.com
534 From: sender@example.com
535 Subject: mhfixmsg decode test 2
537 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
539 This is additional content before the first subpart of the multipart.
541 ------- =_aaaaaaaaaa0
542 Content-Type: multipart/related;
543 type="text/plain"; boundary="subpart__1.1"
546 Content-Type: text/plain; charset="iso-8859-1"
547 Content-Disposition: attachment; filename="test1.txt"
549 This is the first text/plain part, in a subpart.
553 This is additional content after the last subpart of the multipart.
555 ------- =_aaaaaaaaaa0
556 Content-Type: text/plain; charset="iso-8859-1"
557 Content-Disposition: attachment; filename="test2.txt"
558 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
559 Content-Transfer-Encoding: quoted-printable
561 This is the second text/plain part.
563 ------- =_aaaaaaaaaa0
564 Content-Type: text/plain; charset="iso-8859-1"
565 Content-Disposition: attachment; filename="test3.txt"
567 This is the third text/plain part.
569 ------- =_aaaaaaaaaa0
570 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
571 Content-Disposition: attachment; filename="test4.txt"
572 Content-Transfer-Encoding: base64
574 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
576 ------- =_aaaaaaaaaa0--
578 This is additional content after the last subpart of the multipart.
580 run_prog mhfixmsg last
-outfile "$actual"
581 check
"$expected" "$actual"
584 # check attempted (default, 8 bit) -decodetext of binary text
585 #### Generated the encoded text below with:
586 #### $ printf '\275\262=\274\000\n' | base64
587 start_test
"attempted (default, 8 bit) -decodetext of binary text"
588 cat >"`mhpath new`" <<EOF
589 To: recipient@example.com
590 From: sender@example.com
591 Subject: mhfixmsg binary decode test
593 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
595 ------- =_aaaaaaaaaa0
596 Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
597 Content-Transfer-Encoding: base64
601 ------- =_aaaaaaaaaa0--
604 cp -p "`mhpath last`" "$expected"
605 run_prog mhfixmsg last
606 check
"`mhpath last`" "$expected" 'keep first'
609 # check for successful decode of a different part with attempted -decodetext
610 # of binary (>998 characters) text
611 start_test
"for successful decode of a different part with attempted -decodetext"
613 To: recipient@example.com
614 From: sender@example.com
615 Subject: mhfixmsg successful decode of text/plain with failed binary decode
617 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
619 ------- =_aaaaaaaaaa0
620 Content-Type: text/plain; charset="iso-8859-1"
621 Content-Transfer-Encoding: 7bit
623 This is a text plain part
625 ------- =_aaaaaaaaaa0
626 Content-Type: text/html; charset="ascii"
627 Content-Transfer-Encoding: base64
628 Content-Disposition: inline
630 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
631 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
632 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
633 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
634 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
635 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
636 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
637 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
638 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
639 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
640 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
641 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
642 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
643 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
644 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
645 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
646 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
647 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
648 ICA8L2JvZHk+PC9odG1sPg==
650 ------- =_aaaaaaaaaa0--
653 cat >"`mhpath new`" <<EOF
654 To: recipient@example.com
655 From: sender@example.com
656 Subject: mhfixmsg successful decode of text/plain with failed binary decode
658 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
660 ------- =_aaaaaaaaaa0
661 Content-Type: text/plain; charset="iso-8859-1"
662 Content-Transfer-Encoding: base64
664 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
666 ------- =_aaaaaaaaaa0
667 Content-Type: text/html; charset="ascii"
668 Content-Transfer-Encoding: base64
669 Content-Disposition: inline
671 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
672 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
673 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
674 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
675 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
676 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
677 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
678 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
679 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
680 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
681 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
682 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
683 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
684 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
685 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
686 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
687 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
688 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
689 ICA8L2JvZHk+PC9odG1sPg==
691 ------- =_aaaaaaaaaa0--
694 run_prog mhfixmsg
-noreformat last
695 check
"`mhpath last`" "$expected" 'keep first'
698 # check for successful decode of a different part with -decodetext of binary
699 # (>998 characters) text
700 start_test
"for successful decode of a different part with -decodetext of binary"
702 To: recipient@example.com
703 From: sender@example.com
704 Subject: mhfixmsg successful decode of text/plain with failed binary decode
706 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
707 Content-Transfer-Encoding: binary
709 ------- =_aaaaaaaaaa0
710 Content-Type: text/plain; charset="iso-8859-1"
711 Content-Transfer-Encoding: 7bit
713 This is a text plain part
715 ------- =_aaaaaaaaaa0
716 Content-Type: text/html; charset="ascii"
717 Content-Transfer-Encoding: binary
718 Content-Disposition: inline
720 <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>
722 ------- =_aaaaaaaaaa0--
725 run_prog mhfixmsg
-noreformat -decodetext binary last
726 check
"`mhpath last`" "$expected"
729 # check -decodetext of binary (containing ASCII NUL) text
730 start_test
"-decodetext of binary (containing ASCII NUL) text"
731 printf "%s\275\262=\274\000%s" "To: recipient@example.com
732 From: sender@example.com
733 Subject: mhfixmsg binary decode test
735 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
736 Content-Transfer-Encoding: binary
738 ------- =_aaaaaaaaaa0
739 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
740 Content-Transfer-Encoding: binary
744 ------- =_aaaaaaaaaa0--
746 mhfixmsg last
-decodetext binary
-outfile "$actual"
747 check
"$expected" "$actual"
750 # check that -reformat succeeds when decode of binary text fails
751 start_test
"-reformat succeeds when decode of binary text fails"
752 prepare_space
>"$expected" <<'EOF'
754 Date: Thu, 11 Apr 2013 02:47:08 -0700
756 From: <sender@example.com>
757 Subject: body requires binary encoding
758 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
760 ------=_nmh-multipart
761 Content-Type: text/plain; charset="ISO-8859-1"
762 Content-Transfer-Encoding: 7bit
767 Vehicle License Fee $1.84
770 ------=_nmh-multipart
771 Content-Type: text/html; charset="ISO-8859-1"
772 Content-Transfer-Encoding: quoted-printable
777 cat >"`mhpath new`" <<'EOF'
779 Content-Type: text/html; charset="ISO-8859-1"
780 Content-Transfer-Encoding: quoted-printable
781 Date: Thu, 11 Apr 2013 02:47:08 -0700
783 From: <sender@example.com>
784 Subject: body requires binary encoding
787 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
788 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
789 =3D"2"><strong>Mile</strong></font></td><td height=3D"3"> </td><td ali=
790 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
791 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
792 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
793 height=3D"3"> </td><td align=3D"right"><font face=3D"Arial, Helvetica=
794 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
795 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
796 rong>State Tax</strong></font></td><td height=3D"3"> </td><td align=3D=
797 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
798 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
799 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
800 nt></td><td height=3D"3"> </td><td align=3D"right"><font face=3D"Arial=
801 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
802 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
803 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3"> </t=
804 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
805 #333333" size=3D"2">$6.00</font></td></tr>
811 if [ $can_reformat_texthtml -eq 1 ]; then
812 #### lynx inserts multiple blank lines, so squeeze them.
813 #### Truncate to avoid comparing the html portion because it can
814 #### get reformatted.
815 run_prog mhfixmsg last
-outfile - | squeeze_lines
| head -22 >"$actual"
816 check
"$expected" "$actual" 'ignore space'
818 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
824 # Also checks preservation of attributes after one (charset) that is
826 start_test
"-textcharset"
827 cat >"$expected" <<EOF
828 To: recipient@example.com
829 From: sender@example.com
830 Subject: mhfixmsg textcharset test
832 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
833 Content-Transfer-Encoding: 8bit
835 ------- =_aaaaaaaaaa0
836 Content-Type: text/plain; charset="utf-8"; name="square.txt"
837 Content-Disposition: attachment; filename="square.txt"
838 Content-Transfer-Encoding: 8bit
842 ------- =_aaaaaaaaaa0--
845 #### Generated the encoded text below with:
846 #### $ printf '\275\262=\274\n' | base64
847 cat >"`mhpath new`" <<EOF
848 To: recipient@example.com
849 From: sender@example.com
850 Subject: mhfixmsg textcharset test
852 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
854 ------- =_aaaaaaaaaa0
855 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
856 Content-Disposition: attachment; filename="square.txt"
857 Content-Transfer-Encoding: base64
861 ------- =_aaaaaaaaaa0--
864 if test "$ICONV_ENABLED" -eq 1; then
865 run_prog mhfixmsg last
-textcharset utf-8
-outfile "$actual" 2>&1
866 check
"$expected" "$actual"
868 echo "$0: skipping -textcharset check because nmh was built without iconv"
873 # check -nofixboundary
874 start_test
"-nofixboundary"
875 cat >"$expected" <<EOF
878 cat >"`mhpath new`" <<EOF
879 Date: Fri, 13 May 2011 08:21:12 -0500
880 Content-Type: multipart/alternative;
881 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
882 Content-Transfer-Encoding: 8bit
884 From: <sender@example.com>
885 To: <recipient@example.com>
886 Subject: mhfixmsg bad boundary test
888 This is a multi-part message in MIME format.
890 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
891 Content-Type: text/plain
893 The boundaries of this part don't match the header boundary.
895 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
898 cp -p "`mhpath last`" "`mhpath new`"
900 run_test
'mhfixmsg last -nofixboundary' ''
901 check
"$MH_TEST_DIR"/Mail
/inbox
/18 "$MH_TEST_DIR"/Mail
/inbox
/19 'keep first'
904 # check that message is not output when fed through stdin (without -outfile)
905 start_test
"message is not output when fed through stdin"
906 run_prog mhfixmsg
-file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
907 check
"$expected" "$actual"
908 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
909 "$actual.err" >/dev
/null
; then
912 echo "$0: test failed, output is in $actual.err."
913 failed
=`expr ${failed:-0} + 1`
917 # check fixup of erroneous boundary in multipart (-fixboundary,
918 # enabled by default)
920 start_test
"fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
921 cat >"$expected" <<EOF
922 Date: Fri, 13 May 2011 08:21:12 -0500
923 Content-Type: multipart/alternative;
924 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
925 Content-Transfer-Encoding: 8bit
927 From: <sender@example.com>
928 To: <recipient@example.com>
929 Subject: mhfixmsg bad boundary test
931 This is a multi-part message in MIME format.
933 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
934 Content-Type: text/plain
936 The boundaries of this part don't match the header boundary.
938 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
941 run_test
'mhfixmsg last -outfile '"$actual"' -verbose' \
942 "mhfixmsg: 18, fix multipart boundary"
943 check
"$expected" "$actual"
946 # check that message is not modified when -fixboundary fails
947 start_test
"message is not modified when -fixboundary fails"
948 cat >"`mhpath new`" <<EOF
949 Date: Fri, 13 May 2011 08:21:12 -0500
950 Content-Type: multipart/alternative;
951 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
952 Content-Transfer-Encoding: 8bit
954 From: <sender@example.com>
955 To: <recipient@example.com>
956 Subject: mhfixmsg bad boundary test
958 This is a multi-part message in MIME format.
960 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
961 Content-Type: text/plain
963 The boundary below doesn't match the header boundary.
966 NextPart_000_1781A1A_01CC1147.81EBA8D4--
969 cp -p "`mhpath last`" "$expected"
970 run_test
"mhfixmsg last -outfile $actual" ''
971 check
"$expected" "$actual"
974 # check that text/plain part is not added to text/html in multipart/related
975 # when it shouldn't be
976 start_test
"text/plain part is not added to text/html in multipart/related when it shouldn't be"
977 cat >"`mhpath new`" <<EOF
979 Date: Tue, 26 Feb 2013 18:07:20 -0600
980 Subject: multipart/related, not /alternative
981 Content-Type: multipart/related;
982 type="text/html"; boundary="----=_Part_90310_101292502.1"
984 ------=_Part_90310_101292502.1
985 Content-Type: text/html; charset="us-ascii"
986 Content-Transfer-Encoding: 7bit
989 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
990 <title>HTML Content</title>
993 This is the real content.
997 ------=_Part_90310_101292502.1
998 Content-Type: text/plain; charset="us-ascii"
999 Content-Transfer-Encoding: 7bit
1001 Your email client does not support HTML messages
1003 ------=_Part_90310_101292502.1--
1006 cp -p "`mhpath last`" "$expected"
1008 if [ $can_reformat_texthtml -eq 1 ]; then
1009 #### lynx inserts multiple blank lines, so squeeze them.
1010 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1011 check
"$expected" "$actual" 'ignore space'
1017 # check that text/plain part is added to text/html in multipart/related
1019 start_test
"text/plain part is added to text/html in multipart/related when it should be"
1020 cat >"$expected" <<EOF
1022 Date: Tue, 26 Feb 2013 18:07:20 -0600
1023 Subject: multipart/related, not /alternative
1024 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1026 ------=_Part_90310_101292502.1
1027 Content-Type: text/plain; charset="us-ascii"
1028 Content-Transfer-Encoding: 7bit
1030 This is the real content.
1032 ------=_Part_90310_101292502.1
1033 Content-Type: text/html; charset="us-ascii"
1034 Content-Transfer-Encoding: 7bit
1037 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1038 <title>HTML Content</title>
1041 This is the real content.
1045 ------=_Part_90310_101292502.1--
1048 cat >"`mhpath new`" <<EOF
1050 Date: Tue, 26 Feb 2013 18:07:20 -0600
1051 Subject: multipart/related, not /alternative
1052 Content-Type: multipart/related;
1053 type="text/html"; boundary="----=_Part_90310_101292502.1"
1055 ------=_Part_90310_101292502.1
1056 Content-Type: text/html; charset="us-ascii"
1057 Content-Transfer-Encoding: 7bit
1060 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1061 <title>HTML Content</title>
1064 This is the real content.
1068 ------=_Part_90310_101292502.1--
1071 if [ $can_reformat_texthtml -eq 1 ]; then
1072 #### lynx inserts multiple blank lines, so squeeze them.
1073 run_prog mhfixmsg last
-outfile - | squeeze_lines
>"$actual"
1074 check
"$expected" "$actual" 'ignore space'
1080 # check handling of rfc822 message type
1081 # also, checks -fixboundary
1082 start_test
"handling of rfc822 message type"
1083 cat >"$expected" <<EOF
1084 From: Test <test@example.com>
1085 To: Some User <user@example.com>
1086 Date: Fri, 29 Sep 2006 00:00:00
1087 Message-Id: @test.nmh
1088 Subject: message with message/rfc822 attachment
1090 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1092 and some garbage before the attachment
1094 ------- =_aaaaaaaaaa0
1095 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1096 Content-Description: 1552
1097 Content-Disposition: attachment; filename="1552"
1099 From: Test <test@example.com>
1100 To: <another_user@example.com>
1101 Date: Thu, 28 Sep 2006 00:00:00
1102 Message-Id: @test.nmh
1103 Subject: message/rfc822 attachment
1105 This is an RFC-822 message.
1107 ------- =_aaaaaaaaaa0--
1109 and some garbage at the end
1112 cat >"`mhpath new`" <<EOF
1113 From: Test <test@example.com>
1114 To: Some User <user@example.com>
1115 Date: Fri, 29 Sep 2006 00:00:00
1116 Message-Id: @test.nmh
1117 Subject: message with message/rfc822 attachment
1119 Content-Type: multipart/mixed; boundary="----- =badboundary"
1121 and some garbage before the attachment
1123 ------- =_aaaaaaaaaa0
1124 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1125 Content-Description: 1552
1126 Content-Disposition: attachment; filename="1552"
1128 From: Test <test@example.com>
1129 To: <another_user@example.com>
1130 Date: Thu, 28 Sep 2006 00:00:00
1131 Message-Id: @test.nmh
1132 Subject: message/rfc822 attachment
1134 This is an RFC-822 message.
1136 ------- =_aaaaaaaaaa0--
1138 and some garbage at the end
1141 run_test
'mhfixmsg last -outfile '"$actual" ''
1142 check
"$expected" "$actual"
1145 # check not stripping of CRs from ASCII text context (default)
1146 start_test
"not stripping of CRs from ASCII text context (default)"
1147 cat >"$expected" <<EOF
1149 From: sender@example.com
1150 To: recipient@example.com
1151 Subject: message with CR's
1152 Date: Mon, 29 Apr 2013 11:51:45 -0400
1154 There are two CR-LF pairs at the end of this sentence.
1158 cat >"`mhpath new`" <<'EOF'
1160 From: sender@example.com
1161 To: recipient@example.com
1162 Subject: message with CR's
1163 Date: Mon, 29 Apr 2013 11:51:45 -0400
1165 There are two CR-LF pairs at the end of this sentence.
1169 run_prog mhfixmsg last
-outfile "$actual"
1170 check
"$expected" "$actual"
1173 # check stripping of CRs from ASCII text context
1174 start_test
"stripping of CRs from ASCII text context"
1175 cat >"$expected" <<EOF
1177 From: sender@example.com
1178 To: recipient@example.com
1179 Subject: message with CR's
1180 Date: Mon, 29 Apr 2013 11:51:45 -0400
1182 There were two CR-LF pairs at the end of this sentence.
1186 cat >"`mhpath new`" <<'EOF'
1188 From: sender@example.com
1189 To: recipient@example.com
1190 Subject: message with CR's
1191 Date: Mon, 29 Apr 2013 11:51:45 -0400
1193 There were two CR-LF pairs at the end of this sentence.
1197 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks
1198 check
"$expected" "$actual"
1201 # check -replacetextplain
1202 start_test
"-replacetextplain"
1203 prepare_space
>"$expected" <<EOF
1204 To: recipient@example.com
1205 From: sender@example.com
1206 Subject: mhfixmsg replacement of bad text/plain part test
1208 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1211 Content-Type: text/plain; charset="UTF-8"
1212 Content-Transfer-Encoding: 7bit
1214 Yes, the text/plain part really was empty.
1217 Content-Type: text/html; charset="UTF-8"
1218 Content-Disposition: inline
1221 <title>eticket</title>
1224 Yes, the text/plain part really was empty.
1228 ------=_Part_876302--
1231 cat >"`mhpath new`" <<'EOF'
1232 To: recipient@example.com
1233 From: sender@example.com
1234 Subject: mhfixmsg replacement of bad text/plain part test
1236 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1239 Content-Type: text/plain; charset="iso-8859-15"
1240 Content-Transfer-Encoding: 7bit
1241 Content-Disposition: inline
1246 Content-Type: text/html; charset="UTF-8"
1247 Content-Disposition: inline
1250 <title>eticket</title>
1253 Yes, the text/plain part really was empty.
1257 ------=_Part_876302--
1260 if [ $can_reformat_texthtml -eq 1 ]; then
1261 #### lynx inserts multiple blank lines, so squeeze them.
1262 run_prog mhfixmsg last
-replacetextplain -outfile - | \
1263 squeeze_lines
> "$actual"
1264 check
"$expected" "$actual" 'ignore space'
1270 # check -noreplacetextplain
1271 start_test
"-noreplacetextplain"
1272 cat >"$expected" <<EOF
1273 To: recipient@example.com
1274 From: sender@example.com
1275 Subject: mhfixmsg replacement of bad text/plain part test
1277 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1280 Content-Type: text/plain; charset="iso-8859-15"
1281 Content-Transfer-Encoding: 7bit
1282 Content-Disposition: inline
1287 Content-Type: text/html; charset="UTF-8"
1288 Content-Disposition: inline
1291 <title>eticket</title>
1294 Yes, the text/plain part really was empty.
1298 ------=_Part_876302--
1301 run_prog mhfixmsg last
-replacetextplain -noreplacetextplain -outfile "$actual"
1302 check
"$expected" "$actual"
1305 # check removal of extraneous trailing semicolon from header parameter list
1306 start_test
"removal of extraneous trailing semicolon from header parameter list"
1307 cat >"$expected" <<EOF
1308 To: recipient@example.com
1310 From: sender@example.com
1312 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1314 ------- =_aaaaaaaaaa0
1315 Content-Type: text/plain; charset="us-ascii"
1319 ------- =_aaaaaaaaaa0
1320 Content-Type: text/plain; charset="us-ascii";
1322 Content-Description: check folded headers, with and without trailing semicolon
1323 Content-Disposition: attachment;
1328 ------- =_aaaaaaaaaa0--
1331 cat >"`mhpath new`" <<EOF
1332 To: recipient@example.com
1334 From: sender@example.com
1336 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1338 ------- =_aaaaaaaaaa0
1339 Content-Type: text/plain; charset="us-ascii";
1343 ------- =_aaaaaaaaaa0
1344 Content-Type: text/plain; charset="us-ascii";
1346 Content-Description: check folded headers, with and without trailing semicolon
1347 Content-Disposition: attachment;
1352 ------- =_aaaaaaaaaa0--
1354 run_test
'mhfixmsg last -outfile '"$actual" ''
1355 check
"$expected" "$actual"
1358 if [ $can_reformat_texthtml -eq 1 ]; then
1360 start_test
"rmmproc"
1361 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1364 chmod a
+x
"${MH_TEST_DIR}/Mail/rmmproc"
1365 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1366 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1368 run_test
'mhfixmsg 16' ''
1369 check
"${MH_TEST_DIR}/Mail/inbox/16.backup" \
1370 "${MH_TEST_DIR}/Mail/inbox/16.original"
1374 start_test
"-normmproc"
1375 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1377 run_test
'mhfixmsg 21 -normmproc'
1378 check
"${MH_TEST_DIR}/Mail/inbox/22" \
1379 "${MH_TEST_DIR}/Mail/inbox/${sbackup}21" 'keep first'
1384 start_test
"-rmmproc"
1385 run_test
'mhfixmsg 21 -rmmproc true'
1386 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1387 echo check of mhfixmsg
-rmmproc FAILED
, should not have created backup
file
1388 failed
=`expr ${failed:-0} + 1`
1393 start_test
"-fixtype"
1394 cat >"$expected" <<EOF
1395 To: recipient@example.com
1396 From: sender@example.com
1397 Subject: mhfixmsg with incorrect Content-Type
1399 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1401 ------- =_aaaaaaaaaa0
1402 Content-Type: text/plain; name="plaintext.txt"
1406 ------- =_aaaaaaaaaa0--
1409 cat >"`mhpath new`" <<EOF
1410 To: recipient@example.com
1411 From: sender@example.com
1412 Subject: mhfixmsg with incorrect Content-Type
1414 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1416 ------- =_aaaaaaaaaa0
1417 Content-Type: application/octet-stream; name="plaintext.txt"
1421 ------- =_aaaaaaaaaa0--
1424 mhfixmsg
-fixtype application
/octet-stream last
1425 check
"$expected" "`mhpath last`"
1428 # check default -decodetypes
1429 start_test
"default -decodetypes"
1430 cat >$expected <<EOF
1431 To: recipient@example.com
1432 From: sender@example.com
1433 Subject: mhfixmsg decode test 3
1435 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1437 ------- =_aaaaaaaaaa0
1438 Content-Type: text/plain; charset="iso-8859-1"
1439 Content-Disposition: attachment; filename="test1.txt"
1440 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1441 Content-Transfer-Encoding: 7bit
1443 This is the text/plain part.
1445 ------- =_aaaaaaaaaa0
1446 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1447 Content-Disposition: attachment; filename="test2.txt"
1448 Content-Transfer-Encoding: 7bit
1452 This was the text/html part.
1457 ------- =_aaaaaaaaaa0--
1460 cat >"`mhpath new`" <<EOF
1461 To: recipient@example.com
1462 From: sender@example.com
1463 Subject: mhfixmsg decode test 3
1465 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1467 ------- =_aaaaaaaaaa0
1468 Content-Type: text/plain; charset="iso-8859-1"
1469 Content-Disposition: attachment; filename="test1.txt"
1470 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1471 Content-Transfer-Encoding: quoted-printable
1473 This is the text/plain part.
1475 ------- =_aaaaaaaaaa0
1476 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1477 Content-Disposition: attachment; filename="test2.txt"
1478 Content-Transfer-Encoding: base64
1480 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1481 Ym9keT4KPC9odG1sPgo=
1483 ------- =_aaaaaaaaaa0--
1485 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1486 check
"$expected" "$actual"
1489 # check -decodetypes text/plain
1490 start_test
"-decodetypes text/plain"
1491 cat >$expected <<EOF
1492 To: recipient@example.com
1493 From: sender@example.com
1494 Subject: mhfixmsg decode test 4
1496 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1498 ------- =_aaaaaaaaaa0
1499 Content-Type: text/plain; charset="iso-8859-1"
1500 Content-Disposition: attachment; filename="test1.txt"
1501 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1502 Content-Transfer-Encoding: 7bit
1504 This is the text/plain part.
1506 ------- =_aaaaaaaaaa0
1507 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1508 Content-Disposition: attachment; filename="test2.txt"
1509 Content-Transfer-Encoding: base64
1511 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1512 CjwvYm9keT4NCjwvaHRtbD4NCg==
1514 ------- =_aaaaaaaaaa0--
1517 cat >"`mhpath new`" <<EOF
1518 To: recipient@example.com
1519 From: sender@example.com
1520 Subject: mhfixmsg decode test 4
1522 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1524 ------- =_aaaaaaaaaa0
1525 Content-Type: text/plain; charset="iso-8859-1"
1526 Content-Disposition: attachment; filename="test1.txt"
1527 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1528 Content-Transfer-Encoding: quoted-printable
1530 This is the text/plain part.
1532 ------- =_aaaaaaaaaa0
1533 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1534 Content-Disposition: attachment; filename="test2.txt"
1535 Content-Transfer-Encoding: base64
1537 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1538 CjwvYm9keT4NCjwvaHRtbD4NCg==
1540 ------- =_aaaaaaaaaa0--
1542 run_prog mhfixmsg last
-outfile "$actual" -decodetypes text
/plain
-noreformat
1543 check
"$expected" "$actual"
1546 # check -decodetypes attachment/ics
1547 start_test
"-decodetypes attachment/ics"
1548 cat >$expected <<EOF
1549 To: recipient@example.com
1550 From: sender@example.com
1551 Subject: mhfixmsg decode test 5
1553 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1555 ------- =_aaaaaaaaaa0
1556 Content-Type: text/plain; charset="iso-8859-1"
1557 Content-Disposition: attachment; filename="test1.txt"
1558 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1559 Content-Transfer-Encoding: 7bit
1561 This is the text/plain part.
1563 ------- =_aaaaaaaaaa0
1564 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1565 Content-Disposition: attachment; filename="invite.ics"
1566 Content-Transfer-Encoding: 7bit
1572 DTSTAMP:20150101T162400Z
1573 DTSTART:20150105T160000
1574 DTEND:20150105T163000
1575 SUMMARY:4 pm meeting
1579 ------- =_aaaaaaaaaa0--
1582 cat >"`mhpath new`" <<EOF
1583 To: recipient@example.com
1584 From: sender@example.com
1585 Subject: mhfixmsg decode test 5
1587 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1589 ------- =_aaaaaaaaaa0
1590 Content-Type: text/plain; charset="iso-8859-1"
1591 Content-Disposition: attachment; filename="test1.txt"
1592 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1593 Content-Transfer-Encoding: quoted-printable
1598 ------- =_aaaaaaaaaa0
1599 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1600 Content-Disposition: attachment; filename="invite.ics"
1601 Content-Transfer-Encoding: base64
1603 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1604 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1605 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1606 CkVORDpWQ0FMRU5EQVINCg==
1608 ------- =_aaaaaaaaaa0--
1610 run_prog mhfixmsg last
-outfile "$actual" -noreformat
1611 check
"$expected" "$actual"
1614 # check -decodetypes attachment/ics and -nocrlflinebreaks
1615 start_test
"-decodetypes attachment/ics and -nocrlflinebreaks"
1616 cat >$expected <<EOF
1617 To: recipient@example.com
1618 From: sender@example.com
1619 Subject: mhfixmsg decode test 5
1621 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1623 ------- =_aaaaaaaaaa0
1624 Content-Type: text/plain; charset="iso-8859-1"
1625 Content-Disposition: attachment; filename="test1.txt"
1626 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1627 Content-Transfer-Encoding: 7bit
1629 This is the text/plain part.
1631 ------- =_aaaaaaaaaa0
1632 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1633 Content-Disposition: attachment; filename="invite.ics"
1634 Content-Transfer-Encoding: 7bit
1640 DTSTAMP:20150101T162400Z
1641 DTSTART:20150105T160000
1642 DTEND:20150105T163000
1643 SUMMARY:4 pm meeting
1647 ------- =_aaaaaaaaaa0--
1650 cat >"`mhpath new`" <<EOF
1651 To: recipient@example.com
1652 From: sender@example.com
1653 Subject: mhfixmsg decode test 5
1655 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1657 ------- =_aaaaaaaaaa0
1658 Content-Type: text/plain; charset="iso-8859-1"
1659 Content-Disposition: attachment; filename="test1.txt"
1660 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1661 Content-Transfer-Encoding: quoted-printable
1666 ------- =_aaaaaaaaaa0
1667 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1668 Content-Disposition: attachment; filename="invite.ics"
1669 Content-Transfer-Encoding: base64
1671 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1672 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1673 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1674 CkVORDpWQ0FMRU5EQVINCg==
1676 ------- =_aaaaaaaaaa0--
1678 run_prog mhfixmsg last
-outfile "$actual" -nocrlflinebreaks -noreformat
1679 check
"$expected" "$actual"
1682 # check that input is passed through to output when there's a parse error
1683 # (the charset string is missing its closing quote) with -outfile
1684 start_test
"input is passed through to output when there's a parse error"
1685 cat >"$expected.err" <<EOF
1686 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1688 mhfixmsg: unable to parse message 31
1691 cat >"`mhpath new`" <<EOF
1692 To: recipient@example.com
1693 From: sender@example.com
1694 Subject: mhfixmsg pass through on parse error
1696 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1698 ------- =_aaaaaaaaaa0
1699 Content-Type: text/plain; charset="iso-8859-1
1700 Content-Disposition: attachment; filename="test1.txt"
1701 Content-Transfer-Encoding: quoted-printable
1706 ------- =_aaaaaaaaaa0--
1709 run_prog mhfixmsg last
-outfile "$actual" 2>"$actual.err"
1711 #### Expected output is identical to the input message.
1712 check
"`mhpath last`" "$actual" 'keep first'
1713 check
"$expected.err" "$actual.err"
1716 # check that input is passed through to output when there's a parse error
1717 # (the charset string is missing its closing quote) with -outfile, and
1718 # input from stdin. Don't check err output, because it contains the name
1719 # of a tmp file. It's similar to that of the previous check.
1720 start_test
"input is passed through to output when there's a parse error"
1722 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1724 #### Expected output is identical to the input message.
1725 check
"`mhpath last`" "$actual" 'keep first'
1728 start_test
"pass through message with relative folder path with parse error"
1729 #### Factor out leading portion of current folder path and make it relative.
1732 run_prog mhfixmsg
+.
/`mhpath | sed "s%^$pwd/%%"` last
-out - >"$actual" 2>/dev
/null
1734 folder
-f +inbox
>/dev
/null
1735 #### Expected output is identical to the input message.
1736 check
"`mhpath last`" "$actual"
1739 start_test
"fix RFC 2047 encoded header parameters"
1740 #### Also, add C-T-E:8bit to the message headers.
1741 cat >"$expected" <<EOF
1742 To: recipient@example.com
1743 From: sender@example.com
1744 Date: Wed, 28 Sep 2016 11:24:28 -0400
1745 Subject: invalid header parameter encoding
1747 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1748 Content-Transfer-Encoding: 8bit
1750 --001a114dd3e8fe9c56053d92f414
1751 Content-Type: text/plain; charset=UTF-8
1755 --001a114dd3e8fe9c56053d92f414
1756 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1757 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1758 Content-Transfer-Encoding: 8bit
1760 This is the first text/plain part, in a subpart. The file name
1763 --001a114dd3e8fe9c56053d92f414--
1766 cat >"`mhpath new`" <<EOF
1767 To: recipient@example.com
1768 From: sender@example.com
1769 Date: Wed, 28 Sep 2016 11:24:28 -0400
1770 Subject: invalid header parameter encoding
1772 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1774 --001a114dd3e8fe9c56053d92f414
1775 Content-Type: text/plain; charset=UTF-8
1779 --001a114dd3e8fe9c56053d92f414
1780 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1781 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1782 Content-Transfer-Encoding: 8bit
1784 This is the first text/plain part, in a subpart. The file name
1787 --001a114dd3e8fe9c56053d92f414--
1789 run_prog mhfixmsg
-file - -outfile - <`mhpath last` >"$actual" 2>/dev
/null
1790 check
"$expected" "$actual"
1793 # make sure there are no tmp files left over
1794 find "$MH_TEST_DIR/Mail" -name '*mhfix*' -print \
1796 cat >"$expected" <<EOF
1799 check
"$expected" "$actual"