]> diplodocus.org Git - nmh/blob - test/mhfixmsg/test-mhfixmsg
c2070c51ecec86d611a325d493f8bb77f03b2604
[nmh] / test / mhfixmsg / test-mhfixmsg
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhfixmsg
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "${MH_OBJ_DIR}/test/common.sh"
16
17 setup_test
18
19 check_exit '-eq 1' mhfixmsg -
20
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
23
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"
28
29 mhn_defaults="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
30
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}" \
34 >/dev/null; then
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
41 fi
42 else
43 echo "$0: skipping -reformat check because no text browser was found"
44 can_reformat_texthtml=0
45 fi
46
47
48 # check -help
49 start_test "-help"
50 cat >"$expected" <<EOF
51 Usage: mhfixmsg [+folder] [msgs] [switches]
52 switches are:
53 -decodetext 8bit|7bit|binary
54 -nodecodetext
55 -decodetypes
56 -[no]crlflinebreaks
57 -[no]textcharset
58 -[no]reformat
59 -[no]replacetextplain
60 -[no]fixboundary
61 -[no]fixcte
62 -fixtype mimetype
63 -file file
64 -outfile file
65 -rmmproc program
66 -normmproc
67 -[no]changecur
68 -[no]verbose
69 -version
70 -help
71 EOF
72
73 #### Skip nmh intro text.
74 run_prog mhfixmsg -help | sed '/^$/,$d' >"$actual" 2>&1
75 check "$expected" "$actual"
76
77
78 # check -version
79 start_test "-version"
80 case `mhfixmsg -version` in
81 mhfixmsg\ --*) ;;
82 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
83 failed=`expr ${failed:-0} + 1`;;
84 esac
85
86
87 # check that non-MIME messages aren't modified
88 # check -outfile
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'
92
93
94 # check that non-MIME messages with no bodies aren't modified
95 # check -outfile
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
103 EOF
104
105 run_test 'mhfixmsg last -outfile '"$actual" ''
106 check "`mhpath last`" "$actual"
107
108
109 # check -nofixcte
110 start_test "-nofixcte"
111 cat >"`mhpath new`" <<EOF
112 From: Anon
113 To: Mailinglist
114 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
115 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
116 MIME-Version: 1.0
117 Content-Type: MULTIPART/MIXED;
118 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
119 Content-Transfer-Encoding: QUOTED-PRINTABLE
120
121 This message is in MIME format. The first part should be readable
122 text,
123 while the remaining parts are likely unreadable without MIME-aware
124 tools.
125
126 ------=_NextPart_000_0000_00000000.00000000
127 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
128 Content-Transfer-Encoding: 8BIT
129
130 Some text in swedish.
131
132 Varf=C3=B6r inte anv=C3=A4nda...
133
134 ------=_NextPart_000_0000_00000000.00000000--
135
136 And some text after the last part.
137 EOF
138
139 cp -p "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/12
140
141 run_test 'mhfixmsg last -nofixcte' ''
142 check "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/12 'keep first'
143
144
145 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
146 # check -verbose
147 start_test "-fixcte (enabled by default): fixup of erroneous C-T-E in multipart, and -verbose"
148 cat >"$expected" <<EOF
149 From: Anon
150 To: Mailinglist
151 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
152 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
153 MIME-Version: 1.0
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
158
159 This message is in MIME format. The first part should be readable
160 text,
161 while the remaining parts are likely unreadable without MIME-aware
162 tools.
163
164 ------=_NextPart_000_0000_00000000.00000000
165 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
166 Content-Transfer-Encoding: 8BIT
167
168 Some text in swedish.
169
170 Varf=C3=B6r inte anv=C3=A4nda...
171
172 ------=_NextPart_000_0000_00000000.00000000--
173
174 And some text after the last part.
175 EOF
176
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'
181
182 sbackup="`mhparam sbackup`"
183
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
192
193
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
201
202
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'
207
208
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
213 MIME-Version: 1.0
214 From: sender@example.com
215 To: bonquiqui@example.com
216 Subject: rue
217 Date: Sat, 26 Jan 2013 17:37:53 -0500
218 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
219
220 ------=_nmh-multipart
221 Content-Type: text/plain; charset="Windows-1252"
222 Content-Transfer-Encoding: 7bit
223
224 Need to go! Need ... to ... go!
225
226 ------=_nmh-multipart
227 Content-Type: text/html; charset="Windows-1252"
228 Content-Transfer-Encoding: 7bit
229
230 <html>
231 <head>
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>
235 </head>
236 <body>
237 <div>
238 <div>Need to go! Need ... to ... go!</div>
239 </body>
240 </html>
241
242 ------=_nmh-multipart--
243 EOF
244
245 cat >"`mhpath new`" <<EOF
246 MIME-Version: 1.0
247 From: sender@example.com
248 To: bonquiqui@example.com
249 Subject: rue
250 Date: Sat, 26 Jan 2013 17:37:53 -0500
251 Content-Type: text/html; charset="Windows-1252"
252 Content-Transfer-Encoding: quoted-printable
253
254 <html>
255 <head>
256 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
257 252">
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>
261 </head>
262 <body>
263 <div>
264 <div>Need to go! Need ... to ... go!</div>
265 </body>
266 </html>
267 EOF
268
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\"" \
272 >"$expected.err"
273
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"
279 else
280 rm -f "$expected"
281 fi
282
283
284 # check implicit -file with absolute pathname
285 start_test "implicit -file with absolute pathname"
286 run_test "mhfixmsg `mhpath last` -outfile /dev/null" ''
287
288
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
292 MIME-Version: 1.0
293 From: sender@example.com
294 To: bonquiqui@example.com
295 Subject: rue
296 Date: Sat, 26 Jan 2013 17:37:53 -0500
297 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
298
299 ------=_nmh-multipart-3
300 Content-Type: text/plain; charset="Windows-1252"
301 Content-Transfer-Encoding: 7bit
302
303 ------=_nmh-multipart
304 ------=_nmh-multipart-1
305 ------=_nmh-multipart-2
306
307 ------=_nmh-multipart-3
308 Content-Type: text/html; charset="Windows-1252"
309 Content-Transfer-Encoding: 7bit
310
311 <html>
312 <head>
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>
316 </head>
317 <body>
318 ------=_nmh-multipart<br>
319 ------=_nmh-multipart-1<br>
320 ------=_nmh-multipart-2<br>
321 </body>
322 </html>
323
324 ------=_nmh-multipart-3--
325 EOF
326
327 cat >"`mhpath last`" <<EOF
328 MIME-Version: 1.0
329 From: sender@example.com
330 To: bonquiqui@example.com
331 Subject: rue
332 Date: Sat, 26 Jan 2013 17:37:53 -0500
333 Content-Type: text/html; charset="Windows-1252"
334 Content-Transfer-Encoding: quoted-printable
335
336 <html>
337 <head>
338 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
339 252">
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>
343 </head>
344 <body>
345 ------=3D_nmh-multipart<br>
346 ------=3D_nmh-multipart-1<br>
347 ------=3D_nmh-multipart-2<br>
348 </body>
349 </html>
350 EOF
351
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\"" \
355 >"$expected.err"
356
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"
362 else
363 rm -f "$expected"
364 fi
365
366
367 # check -nodecode
368 start_test "-nodecode"
369 prepare_space >"$expected" <<EOF
370 MIME-Version: 1.0
371 From: sender@example.com
372 To: bonquiqui@example.com
373 Subject: rue
374 Date: Sat, 26 Jan 2013 17:37:53 -0500
375 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
376
377 ------=_nmh-multipart
378 Content-Type: text/plain; charset="Windows-1252"
379 Content-Transfer-Encoding: 7bit
380
381 Need to go! Need ... to ... go!
382
383 ------=_nmh-multipart
384 Content-Type: text/html; charset="Windows-1252"
385 Content-Transfer-Encoding: quoted-printable
386
387 <html>
388 <head>
389 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
390 1252">
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>
394 </head>
395 <body>
396 <div>
397 <div>Need to go! Need ... to ... go!</div>
398 </body>
399 </html>
400
401 ------=_nmh-multipart--
402 EOF
403
404 cat >"$MH_TEST_DIR"/Mail/inbox/12 <<EOF
405 MIME-Version: 1.0
406 From: sender@example.com
407 To: bonquiqui@example.com
408 Subject: rue
409 Date: Sat, 26 Jan 2013 17:37:53 -0500
410 Content-Type: text/html; charset="Windows-1252"
411 Content-Transfer-Encoding: quoted-printable
412
413 <html>
414 <head>
415 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
416 252">
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>
420 </head>
421 <body>
422 <div>
423 <div>Need to go! Need ... to ... go!</div>
424 </body>
425 </html>
426 EOF
427
428 if [ $can_reformat_texthtml -eq 1 ]; then
429 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
430
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"
436 else
437 rm -f "$expected"
438 fi
439
440
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
447 MIME-Version: 1.0
448 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
449
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
454
455 This is a text/plain part.
456
457 ------- =_aaaaaaaaaa0--
458 EOF
459
460 cat >"`mhpath new`" <<EOF
461 To: recipient@example.com
462 From: sender@example.com
463 Subject: mhfixmsg decode test 1
464 MIME-Version: 1.0
465 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
466
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
471
472 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
473
474 ------- =_aaaaaaaaaa0--
475 EOF
476
477 run_prog mhfixmsg last -outfile "$actual"
478 check "$expected" "$actual"
479
480
481 # check -decodetext with more complicated content structure
482 start_test "-decodetext with more complicated content structure"
483 cat >$expected <<EOF
484 To: recipient@example.com
485 From: sender@example.com
486 Subject: mhfixmsg decode test 2
487 MIME-Version: 1.0
488 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
489
490 This is additional content before the first subpart of the multipart.
491
492 ------- =_aaaaaaaaaa0
493 Content-Type: multipart/related;
494 type="text/plain"; boundary="subpart__1.1"
495
496 --subpart__1.1
497 Content-Type: text/plain; charset="iso-8859-1"
498 Content-Disposition: attachment; filename="test1.txt"
499
500 This is the first text/plain part, in a subpart.
501
502 --subpart__1.1--
503
504 This is additional content after the last subpart of the multipart.
505
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
511
512 This is the second text/plain part.
513
514 ------- =_aaaaaaaaaa0
515 Content-Type: text/plain; charset="iso-8859-1"
516 Content-Disposition: attachment; filename="test3.txt"
517
518 This is the third text/plain part.
519
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
524
525 This is the fourth text/plain part.
526
527 ------- =_aaaaaaaaaa0--
528
529 This is additional content after the last subpart of the multipart.
530 EOF
531
532 cat >"`mhpath new`" <<EOF
533 To: recipient@example.com
534 From: sender@example.com
535 Subject: mhfixmsg decode test 2
536 MIME-Version: 1.0
537 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
538
539 This is additional content before the first subpart of the multipart.
540
541 ------- =_aaaaaaaaaa0
542 Content-Type: multipart/related;
543 type="text/plain"; boundary="subpart__1.1"
544
545 --subpart__1.1
546 Content-Type: text/plain; charset="iso-8859-1"
547 Content-Disposition: attachment; filename="test1.txt"
548
549 This is the first text/plain part, in a subpart.
550
551 --subpart__1.1--
552
553 This is additional content after the last subpart of the multipart.
554
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
560
561 This is the second text/plain part.
562
563 ------- =_aaaaaaaaaa0
564 Content-Type: text/plain; charset="iso-8859-1"
565 Content-Disposition: attachment; filename="test3.txt"
566
567 This is the third text/plain part.
568
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
573
574 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
575
576 ------- =_aaaaaaaaaa0--
577
578 This is additional content after the last subpart of the multipart.
579 EOF
580 run_prog mhfixmsg last -outfile "$actual"
581 check "$expected" "$actual"
582
583
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
592 MIME-Version: 1.0
593 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
594
595 ------- =_aaaaaaaaaa0
596 Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
597 Content-Transfer-Encoding: base64
598
599 vbI9vAAK
600
601 ------- =_aaaaaaaaaa0--
602 EOF
603
604 cp -p "`mhpath last`" "$expected"
605 run_prog mhfixmsg last
606 check "`mhpath last`" "$expected" 'keep first'
607
608
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"
612 cat >$expected <<EOF
613 To: recipient@example.com
614 From: sender@example.com
615 Subject: mhfixmsg successful decode of text/plain with failed binary decode
616 MIME-Version: 1.0
617 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
618
619 ------- =_aaaaaaaaaa0
620 Content-Type: text/plain; charset="iso-8859-1"
621 Content-Transfer-Encoding: 7bit
622
623 This is a text plain part
624
625 ------- =_aaaaaaaaaa0
626 Content-Type: text/html; charset="ascii"
627 Content-Transfer-Encoding: base64
628 Content-Disposition: inline
629
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==
649
650 ------- =_aaaaaaaaaa0--
651 EOF
652
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
657 MIME-Version: 1.0
658 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
659
660 ------- =_aaaaaaaaaa0
661 Content-Type: text/plain; charset="iso-8859-1"
662 Content-Transfer-Encoding: base64
663
664 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
665
666 ------- =_aaaaaaaaaa0
667 Content-Type: text/html; charset="ascii"
668 Content-Transfer-Encoding: base64
669 Content-Disposition: inline
670
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==
690
691 ------- =_aaaaaaaaaa0--
692 EOF
693
694 run_prog mhfixmsg -noreformat last
695 check "`mhpath last`" "$expected" 'keep first'
696
697
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"
701 cat >$expected <<EOF
702 To: recipient@example.com
703 From: sender@example.com
704 Subject: mhfixmsg successful decode of text/plain with failed binary decode
705 MIME-Version: 1.0
706 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
707 Content-Transfer-Encoding: binary
708
709 ------- =_aaaaaaaaaa0
710 Content-Type: text/plain; charset="iso-8859-1"
711 Content-Transfer-Encoding: 7bit
712
713 This is a text plain part
714
715 ------- =_aaaaaaaaaa0
716 Content-Type: text/html; charset="ascii"
717 Content-Transfer-Encoding: binary
718 Content-Disposition: inline
719
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>
721
722 ------- =_aaaaaaaaaa0--
723 EOF
724
725 run_prog mhfixmsg -noreformat -decodetext binary last
726 check "`mhpath last`" "$expected"
727
728
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
734 MIME-Version: 1.0
735 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
736 Content-Transfer-Encoding: binary
737
738 ------- =_aaaaaaaaaa0
739 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
740 Content-Transfer-Encoding: binary
741
742 " "
743
744 ------- =_aaaaaaaaaa0--
745 " >"$expected"
746 mhfixmsg last -decodetext binary -outfile "$actual"
747 check "$expected" "$actual"
748
749
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'
753 MIME-Version: 1.0
754 Date: Thu, 11 Apr 2013 02:47:08 -0700
755 To: <me@example.com>
756 From: <sender@example.com>
757 Subject: body requires binary encoding
758 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
759
760 ------=_nmh-multipart
761 Content-Type: text/plain; charset="ISO-8859-1"
762 Content-Transfer-Encoding: 7bit
763
764 Mile $0.00
765 Time $78.71
766 State Tax $5.90
767 Vehicle License Fee $1.84
768 State Txn Tax $6.00
769
770 ------=_nmh-multipart
771 Content-Type: text/html; charset="ISO-8859-1"
772 Content-Transfer-Encoding: quoted-printable
773
774 <body>
775 EOF
776
777 cat >"`mhpath new`" <<'EOF'
778 MIME-Version: 1.0
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
782 To: <me@example.com>
783 From: <sender@example.com>
784 Subject: body requires binary encoding
785
786 <body>
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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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>
806
807 </body>
808 </html>
809 EOF
810
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'
817 else
818 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
819 rm -f "$expected"
820 fi
821
822
823 # check -textcharset
824 # Also checks preservation of attributes after one (charset) that is
825 # modified.
826 start_test "-textcharset"
827 cat >"$expected" <<EOF
828 To: recipient@example.com
829 From: sender@example.com
830 Subject: mhfixmsg textcharset test
831 MIME-Version: 1.0
832 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
833 Content-Transfer-Encoding: 8bit
834
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
839
840 ½²=¼
841
842 ------- =_aaaaaaaaaa0--
843 EOF
844
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
851 MIME-Version: 1.0
852 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
853
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
858
859 vbI9vAo=
860
861 ------- =_aaaaaaaaaa0--
862 EOF
863
864 if test "$ICONV_ENABLED" -eq 1; then
865 run_prog mhfixmsg last -textcharset utf-8 -outfile "$actual" 2>&1
866 check "$expected" "$actual"
867 else
868 echo "$0: skipping -textcharset check because nmh was built without iconv"
869 rm -f "$expected"
870 fi
871
872
873 # check -nofixboundary
874 start_test "-nofixboundary"
875 cat >"$expected" <<EOF
876 EOF
877
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
883 MIME-Version: 1.0
884 From: <sender@example.com>
885 To: <recipient@example.com>
886 Subject: mhfixmsg bad boundary test
887
888 This is a multi-part message in MIME format.
889
890 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
891 Content-Type: text/plain
892
893 The boundaries of this part don't match the header boundary.
894
895 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
896 EOF
897
898 cp -p "`mhpath last`" "`mhpath new`"
899
900 run_test 'mhfixmsg last -nofixboundary' ''
901 check "$MH_TEST_DIR"/Mail/inbox/18 "$MH_TEST_DIR"/Mail/inbox/19 'keep first'
902
903
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
910 rm -f "$actual.err"
911 else
912 echo "$0: test failed, output is in $actual.err."
913 failed=`expr ${failed:-0} + 1`
914 fi
915
916
917 # check fixup of erroneous boundary in multipart (-fixboundary,
918 # enabled by default)
919 # check -verbose
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
926 MIME-Version: 1.0
927 From: <sender@example.com>
928 To: <recipient@example.com>
929 Subject: mhfixmsg bad boundary test
930
931 This is a multi-part message in MIME format.
932
933 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
934 Content-Type: text/plain
935
936 The boundaries of this part don't match the header boundary.
937
938 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
939 EOF
940
941 run_test 'mhfixmsg last -outfile '"$actual"' -verbose' \
942 "mhfixmsg: 18, fix multipart boundary"
943 check "$expected" "$actual"
944
945
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
953 MIME-Version: 1.0
954 From: <sender@example.com>
955 To: <recipient@example.com>
956 Subject: mhfixmsg bad boundary test
957
958 This is a multi-part message in MIME format.
959
960 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
961 Content-Type: text/plain
962
963 The boundary below doesn't match the header boundary.
964
965 ------=_
966 NextPart_000_1781A1A_01CC1147.81EBA8D4--
967 EOF
968
969 cp -p "`mhpath last`" "$expected"
970 run_test "mhfixmsg last -outfile $actual" ''
971 check "$expected" "$actual"
972
973
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
978 MIME-Version: 1.0
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"
983
984 ------=_Part_90310_101292502.1
985 Content-Type: text/html; charset="us-ascii"
986 Content-Transfer-Encoding: 7bit
987
988 <html><head>
989 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
990 <title>HTML Content</title>
991 </head>
992 <body>
993 This is the real content.
994 </body>
995 </html>
996
997 ------=_Part_90310_101292502.1
998 Content-Type: text/plain; charset="us-ascii"
999 Content-Transfer-Encoding: 7bit
1000
1001 Your email client does not support HTML messages
1002
1003 ------=_Part_90310_101292502.1--
1004 EOF
1005
1006 cp -p "`mhpath last`" "$expected"
1007
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'
1012 else
1013 rm -f "$expected"
1014 fi
1015
1016
1017 # check that text/plain part is added to text/html in multipart/related
1018 # when it should be
1019 start_test "text/plain part is added to text/html in multipart/related when it should be"
1020 cat >"$expected" <<EOF
1021 MIME-Version: 1.0
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"
1025
1026 ------=_Part_90310_101292502.1
1027 Content-Type: text/plain; charset="us-ascii"
1028 Content-Transfer-Encoding: 7bit
1029
1030 This is the real content.
1031
1032 ------=_Part_90310_101292502.1
1033 Content-Type: text/html; charset="us-ascii"
1034 Content-Transfer-Encoding: 7bit
1035
1036 <html><head>
1037 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1038 <title>HTML Content</title>
1039 </head>
1040 <body>
1041 This is the real content.
1042 </body>
1043 </html>
1044
1045 ------=_Part_90310_101292502.1--
1046 EOF
1047
1048 cat >"`mhpath new`" <<EOF
1049 MIME-Version: 1.0
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"
1054
1055 ------=_Part_90310_101292502.1
1056 Content-Type: text/html; charset="us-ascii"
1057 Content-Transfer-Encoding: 7bit
1058
1059 <html><head>
1060 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1061 <title>HTML Content</title>
1062 </head>
1063 <body>
1064 This is the real content.
1065 </body>
1066 </html>
1067
1068 ------=_Part_90310_101292502.1--
1069 EOF
1070
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'
1075 else
1076 rm -f "$expected"
1077 fi
1078
1079
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
1089 MIME-Version: 1.0
1090 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1091
1092 and some garbage before the attachment
1093
1094 ------- =_aaaaaaaaaa0
1095 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1096 Content-Description: 1552
1097 Content-Disposition: attachment; filename="1552"
1098
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
1104
1105 This is an RFC-822 message.
1106
1107 ------- =_aaaaaaaaaa0--
1108
1109 and some garbage at the end
1110 EOF
1111
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
1118 MIME-Version: 1.0
1119 Content-Type: multipart/mixed; boundary="----- =badboundary"
1120
1121 and some garbage before the attachment
1122
1123 ------- =_aaaaaaaaaa0
1124 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1125 Content-Description: 1552
1126 Content-Disposition: attachment; filename="1552"
1127
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
1133
1134 This is an RFC-822 message.
1135
1136 ------- =_aaaaaaaaaa0--
1137
1138 and some garbage at the end
1139 EOF
1140
1141 run_test 'mhfixmsg last -outfile '"$actual" ''
1142 check "$expected" "$actual"
1143
1144
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
1148 MIME-Version: 1.0
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
1153
1154 There are two CR-LF pairs at the end of this sentence.
1155
1156 EOF
1157
1158 cat >"`mhpath new`" <<'EOF'
1159 MIME-Version: 1.0
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
1164
1165 There are two CR-LF pairs at the end of this sentence.
1166
1167 EOF
1168
1169 run_prog mhfixmsg last -outfile "$actual"
1170 check "$expected" "$actual"
1171
1172
1173 # check stripping of CRs from ASCII text context
1174 start_test "stripping of CRs from ASCII text context"
1175 cat >"$expected" <<EOF
1176 MIME-Version: 1.0
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
1181
1182 There were two CR-LF pairs at the end of this sentence.
1183
1184 EOF
1185
1186 cat >"`mhpath new`" <<'EOF'
1187 MIME-Version: 1.0
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
1192
1193 There were two CR-LF pairs at the end of this sentence.
1194
1195 EOF
1196
1197 run_prog mhfixmsg last -outfile "$actual" -nocrlflinebreaks
1198 check "$expected" "$actual"
1199
1200
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
1207 MIME-Version: 1.0
1208 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1209
1210 ------=_Part_876302
1211 Content-Type: text/plain; charset="UTF-8"
1212 Content-Transfer-Encoding: 7bit
1213
1214 Yes, the text/plain part really was empty.
1215
1216 ------=_Part_876302
1217 Content-Type: text/html; charset="UTF-8"
1218 Content-Disposition: inline
1219
1220 <html><head>
1221 <title>eticket</title>
1222 </head>
1223 <body>
1224 Yes, the text/plain part really was empty.
1225 </body>
1226 </html>
1227
1228 ------=_Part_876302--
1229 EOF
1230
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
1235 MIME-Version: 1.0
1236 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1237
1238 ------=_Part_876302
1239 Content-Type: text/plain; charset="iso-8859-15"
1240 Content-Transfer-Encoding: 7bit
1241 Content-Disposition: inline
1242
1243
1244
1245 ------=_Part_876302
1246 Content-Type: text/html; charset="UTF-8"
1247 Content-Disposition: inline
1248
1249 <html><head>
1250 <title>eticket</title>
1251 </head>
1252 <body>
1253 Yes, the text/plain part really was empty.
1254 </body>
1255 </html>
1256
1257 ------=_Part_876302--
1258 EOF
1259
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'
1265 else
1266 rm -f "$expected"
1267 fi
1268
1269
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
1276 MIME-Version: 1.0
1277 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1278
1279 ------=_Part_876302
1280 Content-Type: text/plain; charset="iso-8859-15"
1281 Content-Transfer-Encoding: 7bit
1282 Content-Disposition: inline
1283
1284
1285
1286 ------=_Part_876302
1287 Content-Type: text/html; charset="UTF-8"
1288 Content-Disposition: inline
1289
1290 <html><head>
1291 <title>eticket</title>
1292 </head>
1293 <body>
1294 Yes, the text/plain part really was empty.
1295 </body>
1296 </html>
1297
1298 ------=_Part_876302--
1299 EOF
1300
1301 run_prog mhfixmsg last -replacetextplain -noreplacetextplain -outfile "$actual"
1302 check "$expected" "$actual"
1303
1304
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
1309 Subject: test
1310 From: sender@example.com
1311 MIME-Version: 1.0
1312 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1313
1314 ------- =_aaaaaaaaaa0
1315 Content-Type: text/plain; charset="us-ascii"
1316
1317 test
1318
1319 ------- =_aaaaaaaaaa0
1320 Content-Type: text/plain; charset="us-ascii";
1321 name="DATE"
1322 Content-Description: check folded headers, with and without trailing semicolon
1323 Content-Disposition: attachment;
1324 filename="DATE"
1325
1326 14 April 2014
1327
1328 ------- =_aaaaaaaaaa0--
1329 EOF
1330
1331 cat >"`mhpath new`" <<EOF
1332 To: recipient@example.com
1333 Subject: test
1334 From: sender@example.com
1335 MIME-Version: 1.0
1336 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1337
1338 ------- =_aaaaaaaaaa0
1339 Content-Type: text/plain; charset="us-ascii";
1340
1341 test
1342
1343 ------- =_aaaaaaaaaa0
1344 Content-Type: text/plain; charset="us-ascii";
1345 name="DATE"
1346 Content-Description: check folded headers, with and without trailing semicolon
1347 Content-Disposition: attachment;
1348 filename="DATE";
1349
1350 14 April 2014
1351
1352 ------- =_aaaaaaaaaa0--
1353 EOF
1354 run_test 'mhfixmsg last -outfile '"$actual" ''
1355 check "$expected" "$actual"
1356
1357
1358 if [ $can_reformat_texthtml -eq 1 ]; then
1359 # check rmmproc
1360 start_test "rmmproc"
1361 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1362 mv "$1" "$1.backup"
1363 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"
1367
1368 run_test 'mhfixmsg 16' ''
1369 check "${MH_TEST_DIR}/Mail/inbox/16.backup" \
1370 "${MH_TEST_DIR}/Mail/inbox/16.original"
1371
1372
1373 # check -normmproc
1374 start_test "-normmproc"
1375 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1376
1377 run_test 'mhfixmsg 21 -normmproc'
1378 check "${MH_TEST_DIR}/Mail/inbox/22" \
1379 "${MH_TEST_DIR}/Mail/inbox/${sbackup}21" 'keep first'
1380 fi
1381
1382
1383 # check -rmmproc
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`
1389 fi
1390
1391
1392 # check -fixtype
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
1398 MIME-Version: 1.0
1399 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1400
1401 ------- =_aaaaaaaaaa0
1402 Content-Type: text/plain; name="plaintext.txt"
1403
1404 this is plain text
1405
1406 ------- =_aaaaaaaaaa0--
1407 EOF
1408
1409 cat >"`mhpath new`" <<EOF
1410 To: recipient@example.com
1411 From: sender@example.com
1412 Subject: mhfixmsg with incorrect Content-Type
1413 MIME-Version: 1.0
1414 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1415
1416 ------- =_aaaaaaaaaa0
1417 Content-Type: application/octet-stream; name="plaintext.txt"
1418
1419 this is plain text
1420
1421 ------- =_aaaaaaaaaa0--
1422 EOF
1423
1424 mhfixmsg -fixtype application/octet-stream last
1425 check "$expected" "`mhpath last`"
1426
1427
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
1434 MIME-Version: 1.0
1435 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1436
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
1442
1443 This is the text/plain part.
1444
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
1449
1450 <html>
1451 <head>
1452 This was the text/html part.
1453 </head>
1454 </body>
1455 </html>
1456
1457 ------- =_aaaaaaaaaa0--
1458 EOF
1459
1460 cat >"`mhpath new`" <<EOF
1461 To: recipient@example.com
1462 From: sender@example.com
1463 Subject: mhfixmsg decode test 3
1464 MIME-Version: 1.0
1465 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1466
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
1472
1473 This is the text/plain part.
1474
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
1479
1480 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1481 Ym9keT4KPC9odG1sPgo=
1482
1483 ------- =_aaaaaaaaaa0--
1484 EOF
1485 run_prog mhfixmsg last -outfile "$actual" -noreformat
1486 check "$expected" "$actual"
1487
1488
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
1495 MIME-Version: 1.0
1496 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1497
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
1503
1504 This is the text/plain part.
1505
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
1510
1511 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1512 CjwvYm9keT4NCjwvaHRtbD4NCg==
1513
1514 ------- =_aaaaaaaaaa0--
1515 EOF
1516
1517 cat >"`mhpath new`" <<EOF
1518 To: recipient@example.com
1519 From: sender@example.com
1520 Subject: mhfixmsg decode test 4
1521 MIME-Version: 1.0
1522 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1523
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
1529
1530 This is the text/plain part.
1531
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
1536
1537 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1538 CjwvYm9keT4NCjwvaHRtbD4NCg==
1539
1540 ------- =_aaaaaaaaaa0--
1541 EOF
1542 run_prog mhfixmsg last -outfile "$actual" -decodetypes text/plain -noreformat
1543 check "$expected" "$actual"
1544
1545
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
1552 MIME-Version: 1.0
1553 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1554
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
1560
1561 This is the text/plain part.
1562
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
1567
1568 BEGIN:VCALENDAR
1569 VERSION:2.0
1570 PRODID:test-mhical
1571 BEGIN:VEVENT
1572 DTSTAMP:20150101T162400Z
1573 DTSTART:20150105T160000
1574 DTEND:20150105T163000
1575 SUMMARY:4 pm meeting
1576 END:VEVENT
1577 END:VCALENDAR
1578
1579 ------- =_aaaaaaaaaa0--
1580 EOF
1581
1582 cat >"`mhpath new`" <<EOF
1583 To: recipient@example.com
1584 From: sender@example.com
1585 Subject: mhfixmsg decode test 5
1586 MIME-Version: 1.0
1587 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1588
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
1594
1595 This is the=
1596 text/plain part.
1597
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
1602
1603 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1604 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1605 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1606 CkVORDpWQ0FMRU5EQVINCg==
1607
1608 ------- =_aaaaaaaaaa0--
1609 EOF
1610 run_prog mhfixmsg last -outfile "$actual" -noreformat
1611 check "$expected" "$actual"
1612
1613
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
1620 MIME-Version: 1.0
1621 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1622
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
1628
1629 This is the text/plain part.
1630
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
1635
1636 BEGIN:VCALENDAR
1637 VERSION:2.0
1638 PRODID:test-mhical
1639 BEGIN:VEVENT
1640 DTSTAMP:20150101T162400Z
1641 DTSTART:20150105T160000
1642 DTEND:20150105T163000
1643 SUMMARY:4 pm meeting
1644 END:VEVENT
1645 END:VCALENDAR
1646
1647 ------- =_aaaaaaaaaa0--
1648 EOF
1649
1650 cat >"`mhpath new`" <<EOF
1651 To: recipient@example.com
1652 From: sender@example.com
1653 Subject: mhfixmsg decode test 5
1654 MIME-Version: 1.0
1655 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1656
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
1662
1663 This is the=
1664 text/plain part.
1665
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
1670
1671 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1672 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1673 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1674 CkVORDpWQ0FMRU5EQVINCg==
1675
1676 ------- =_aaaaaaaaaa0--
1677 EOF
1678 run_prog mhfixmsg last -outfile "$actual" -nocrlflinebreaks -noreformat
1679 check "$expected" "$actual"
1680
1681
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
1687 (parameter charset)
1688 mhfixmsg: unable to parse message 31
1689 EOF
1690
1691 cat >"`mhpath new`" <<EOF
1692 To: recipient@example.com
1693 From: sender@example.com
1694 Subject: mhfixmsg pass through on parse error
1695 MIME-Version: 1.0
1696 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1697
1698 ------- =_aaaaaaaaaa0
1699 Content-Type: text/plain; charset="iso-8859-1
1700 Content-Disposition: attachment; filename="test1.txt"
1701 Content-Transfer-Encoding: quoted-printable
1702
1703 This is the=
1704 text/plain part.
1705
1706 ------- =_aaaaaaaaaa0--
1707 EOF
1708 set +e
1709 run_prog mhfixmsg last -outfile "$actual" 2>"$actual.err"
1710 set -e
1711 #### Expected output is identical to the input message.
1712 check "`mhpath last`" "$actual" 'keep first'
1713 check "$expected.err" "$actual.err"
1714
1715
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"
1721 set +e
1722 run_prog mhfixmsg -file - -outfile - <`mhpath last` >"$actual" 2>/dev/null
1723 set -e
1724 #### Expected output is identical to the input message.
1725 check "`mhpath last`" "$actual" 'keep first'
1726
1727
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.
1730 pwd=`pwd`
1731 set +e
1732 run_prog mhfixmsg +./`mhpath | sed "s%^$pwd/%%"` last -out - >"$actual" 2>/dev/null
1733 set -e
1734 folder -f +inbox >/dev/null
1735 #### Expected output is identical to the input message.
1736 check "`mhpath last`" "$actual"
1737
1738
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
1746 MIME-Version: 1.0
1747 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1748 Content-Transfer-Encoding: 8bit
1749
1750 --001a114dd3e8fe9c56053d92f414
1751 Content-Type: text/plain; charset=UTF-8
1752
1753 This is a test.
1754
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
1759
1760 This is the first text/plain part, in a subpart. The file name
1761 is testø.txt.
1762
1763 --001a114dd3e8fe9c56053d92f414--
1764 EOF
1765
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
1771 MIME-Version: 1.0
1772 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1773
1774 --001a114dd3e8fe9c56053d92f414
1775 Content-Type: text/plain; charset=UTF-8
1776
1777 This is a test.
1778
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
1783
1784 This is the first text/plain part, in a subpart. The file name
1785 is testø.txt.
1786
1787 --001a114dd3e8fe9c56053d92f414--
1788 EOF
1789 run_prog mhfixmsg -file - -outfile - <`mhpath last` >"$actual" 2>/dev/null
1790 check "$expected" "$actual"
1791
1792
1793 # make sure there are no tmp files left over
1794 find "$MH_TEST_DIR/Mail" -name '*mhfix*' -print \
1795 >"$actual"
1796 cat >"$expected" <<EOF
1797 EOF
1798
1799 check "$expected" "$actual"
1800
1801 finish_test
1802 exit $failed