]> diplodocus.org Git - nmh/blob - test/mhfixmsg/test-mhfixmsg
Reverted commit 9a4b4a3d3b27fe4a7ff6d0b8724ce1c06b5917eb.
[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}" \
32 >/dev/null; then
33 can_reformat_texthtml=1
34 if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
35 >/dev/null; then
36 #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To
37 #### support testing with non-writeable $HOME, and to not leave
38 #### relics from this test if it is writeable but doesn't already
39 #### have a .w3m, and to not depend on whatever is in that if it
40 #### does already exist, overwrite $HOME if using w3m.
41 HOME="$MHTMPDIR"; export HOME
42 fi
43 else
44 echo "$0: skipping -reformat check because no text browser was found"
45 can_reformat_texthtml=0
46 fi
47
48
49 # check -help
50 start_test "-help"
51 cat >"$expected" <<EOF
52 Usage: mhfixmsg [+folder] [msgs] [switches]
53 switches are:
54 -decodetext 8bit|7bit|binary
55 -nodecodetext
56 -decodetypes
57 -[no]crlflinebreaks
58 -[no]textcharset
59 -[no]reformat
60 -[no]replacetextplain
61 -[no]fixboundary
62 -[no]fixcte
63 -fixtype mimetype
64 -file file
65 -outfile file
66 -rmmproc program
67 -normmproc
68 -[no]changecur
69 -[no]verbose
70 -version
71 -help
72 EOF
73
74 #### Skip nmh intro text.
75 run_prog mhfixmsg -help | sed '/^$/,$d' >"$actual" 2>&1
76 check "$expected" "$actual"
77
78
79 # check -version
80 start_test "-version"
81 case `mhfixmsg -version` in
82 mhfixmsg\ --*) ;;
83 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
84 failed=`expr ${failed:-0} + 1`;;
85 esac
86
87
88 # check that non-MIME messages aren't modified
89 # check -outfile
90 start_test "non-MIME messages aren't modified, and -outfile"
91 run_test 'mhfixmsg first -outfile '"$actual" ''
92 check "`mhpath first`" "$actual" 'keep first'
93
94
95 # check that non-MIME messages with no bodies aren't modified
96 # check -outfile
97 start_test "non-MIME messages with no bodies aren't modified, and -outfile"
98 cat >"`mhpath new`" <<EOF
99 From: Test <test@example.com>
100 To: Some User <user@example.com>
101 Date: Fri, 29 Sep 2006 00:00:00
102 Message-Id: @test.nmh
103 Subject: message with no body
104 EOF
105
106 run_test 'mhfixmsg last -outfile '"$actual" ''
107 check "`mhpath last`" "$actual"
108
109
110 # check -nofixcte
111 start_test "-nofixcte"
112 cat >"`mhpath new`" <<EOF
113 From: Anon
114 To: Mailinglist
115 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
116 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
117 MIME-Version: 1.0
118 Content-Type: MULTIPART/MIXED;
119 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
120 Content-Transfer-Encoding: QUOTED-PRINTABLE
121
122 This message is in MIME format. The first part should be readable
123 text,
124 while the remaining parts are likely unreadable without MIME-aware
125 tools.
126
127 ------=_NextPart_000_0000_00000000.00000000
128 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
129 Content-Transfer-Encoding: 8BIT
130
131 Some text in swedish.
132
133 Varf=C3=B6r inte anv=C3=A4nda...
134
135 ------=_NextPart_000_0000_00000000.00000000--
136
137 And some text after the last part.
138 EOF
139
140 cp -p "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/12
141
142 run_test 'mhfixmsg last -nofixcte' ''
143 check "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/12 'keep first'
144
145
146 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
147 # check -verbose
148 start_test "-fixcte (enabled by default): fixup of erroneous C-T-E in multipart, and -verbose"
149 cat >"$expected" <<EOF
150 From: Anon
151 To: Mailinglist
152 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
153 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
154 MIME-Version: 1.0
155 Content-Type: MULTIPART/MIXED;
156 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
157 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
158 Content-Transfer-Encoding: 8bit
159
160 This message is in MIME format. The first part should be readable
161 text,
162 while the remaining parts are likely unreadable without MIME-aware
163 tools.
164
165 ------=_NextPart_000_0000_00000000.00000000
166 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
167 Content-Transfer-Encoding: 8BIT
168
169 Some text in swedish.
170
171 Varf=C3=B6r inte anv=C3=A4nda...
172
173 ------=_NextPart_000_0000_00000000.00000000--
174
175 And some text after the last part.
176 EOF
177
178 run_test 'mhfixmsg last -outfile '"$actual"' -verbose' \
179 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
180 QUOTED-PRINTABLE with 8 bit"
181 check "$expected" "$actual" 'keep first'
182
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/,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/,11 "$MH_TEST_DIR"/Mail/inbox/11.original
201
202
203 # check -reformat (enabled by default): addition of text/plain part
204 # to solitary text/html part
205 start_test "-reformat (enabled by default): addition of text/plain part"
206 prepare_space >"$expected" <<EOF
207 MIME-Version: 1.0
208 From: sender@example.com
209 To: bonquiqui@example.com
210 Subject: rue
211 Date: Sat, 26 Jan 2013 17:37:53 -0500
212 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
213
214 ------=_nmh-multipart
215 Content-Type: text/plain; charset="Windows-1252"
216 Content-Transfer-Encoding: 7bit
217
218 Need to go! Need ... to ... go!
219
220 ------=_nmh-multipart
221 Content-Type: text/html; charset="Windows-1252"
222 Content-Transfer-Encoding: 7bit
223
224 <html>
225 <head>
226 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
227 <meta name="Generator" content="Microsoft Exchange Server">
228 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
229 </head>
230 <body>
231 <div>
232 <div>Need to go! Need ... to ... go!</div>
233 </body>
234 </html>
235
236 ------=_nmh-multipart--
237 EOF
238
239 cat >"`mhpath new`" <<EOF
240 MIME-Version: 1.0
241 From: sender@example.com
242 To: bonquiqui@example.com
243 Subject: rue
244 Date: Sat, 26 Jan 2013 17:37:53 -0500
245 Content-Type: text/html; charset="Windows-1252"
246 Content-Transfer-Encoding: quoted-printable
247
248 <html>
249 <head>
250 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
251 252">
252 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
253 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
254 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
255 </head>
256 <body>
257 <div>
258 <div>Need to go! Need ... to ... go!</div>
259 </body>
260 </html>
261 EOF
262
263 if [ $can_reformat_texthtml -eq 1 ]; then
264 printf '%s\n' "mhfixmsg: 12, insert text/plain part
265 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
266 >"$expected.err"
267
268 #### lynx inserts multiple blank lines, so squeeze them.
269 run_prog mhfixmsg last -outfile - -verbose 2>"$actual.err" | \
270 squeeze_lines >"$actual"
271 check "$expected" "$actual" 'ignore space'
272 check "$expected.err" "$actual.err"
273 else
274 rm -f "$expected"
275 fi
276
277
278 # check implicit -file with absolute pathname
279 start_test "implicit -file with absolute pathname"
280 run_test "mhfixmsg `mhpath last` -outfile /dev/null" ''
281
282
283 # check handling of boundary string that appears in message body
284 start_test "handling of boundary string that appears in message body"
285 prepare_space >"$expected" <<EOF
286 MIME-Version: 1.0
287 From: sender@example.com
288 To: bonquiqui@example.com
289 Subject: rue
290 Date: Sat, 26 Jan 2013 17:37:53 -0500
291 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
292
293 ------=_nmh-multipart-3
294 Content-Type: text/plain; charset="Windows-1252"
295 Content-Transfer-Encoding: 7bit
296
297 ------=_nmh-multipart
298 ------=_nmh-multipart-1
299 ------=_nmh-multipart-2
300
301 ------=_nmh-multipart-3
302 Content-Type: text/html; charset="Windows-1252"
303 Content-Transfer-Encoding: 7bit
304
305 <html>
306 <head>
307 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
308 <meta name="Generator" content="Microsoft Exchange Server">
309 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
310 </head>
311 <body>
312 ------=_nmh-multipart<br>
313 ------=_nmh-multipart-1<br>
314 ------=_nmh-multipart-2<br>
315 </body>
316 </html>
317
318 ------=_nmh-multipart-3--
319 EOF
320
321 cat >"`mhpath last`" <<EOF
322 MIME-Version: 1.0
323 From: sender@example.com
324 To: bonquiqui@example.com
325 Subject: rue
326 Date: Sat, 26 Jan 2013 17:37:53 -0500
327 Content-Type: text/html; charset="Windows-1252"
328 Content-Transfer-Encoding: quoted-printable
329
330 <html>
331 <head>
332 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
333 252">
334 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
335 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
336 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
337 </head>
338 <body>
339 ------=3D_nmh-multipart<br>
340 ------=3D_nmh-multipart-1<br>
341 ------=3D_nmh-multipart-2<br>
342 </body>
343 </html>
344 EOF
345
346 if [ $can_reformat_texthtml -eq 1 ]; then
347 printf '%s\n' "mhfixmsg: 12, insert text/plain part
348 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
349 >"$expected.err"
350
351 #### lynx inserts multiple blank lines, so squeeze them.
352 run_prog mhfixmsg last -outfile - -verbose 2>"$actual.err" | \
353 squeeze_lines >"$actual"
354 check "$expected" "$actual" 'ignore space'
355 check "$expected.err" "$actual.err"
356 else
357 rm -f "$expected"
358 fi
359
360
361 # check -nodecode
362 start_test "-nodecode"
363 prepare_space >"$expected" <<EOF
364 MIME-Version: 1.0
365 From: sender@example.com
366 To: bonquiqui@example.com
367 Subject: rue
368 Date: Sat, 26 Jan 2013 17:37:53 -0500
369 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
370
371 ------=_nmh-multipart
372 Content-Type: text/plain; charset="Windows-1252"
373 Content-Transfer-Encoding: 7bit
374
375 Need to go! Need ... to ... go!
376
377 ------=_nmh-multipart
378 Content-Type: text/html; charset="Windows-1252"
379 Content-Transfer-Encoding: quoted-printable
380
381 <html>
382 <head>
383 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
384 1252">
385 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
386 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
387 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
388 </head>
389 <body>
390 <div>
391 <div>Need to go! Need ... to ... go!</div>
392 </body>
393 </html>
394
395 ------=_nmh-multipart--
396 EOF
397
398 cat >"$MH_TEST_DIR"/Mail/inbox/12 <<EOF
399 MIME-Version: 1.0
400 From: sender@example.com
401 To: bonquiqui@example.com
402 Subject: rue
403 Date: Sat, 26 Jan 2013 17:37:53 -0500
404 Content-Type: text/html; charset="Windows-1252"
405 Content-Transfer-Encoding: quoted-printable
406
407 <html>
408 <head>
409 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
410 252">
411 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
412 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
413 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
414 </head>
415 <body>
416 <div>
417 <div>Need to go! Need ... to ... go!</div>
418 </body>
419 </html>
420 EOF
421
422 if [ $can_reformat_texthtml -eq 1 ]; then
423 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
424
425 #### lynx inserts multiple blank lines, so squeeze them.
426 run_prog mhfixmsg last -nodecode -outfile - -verbose 2>"$actual.err" | \
427 squeeze_lines >"$actual"
428 check "$expected" "$actual" 'ignore space'
429 check "$expected.err" "$actual.err"
430 else
431 rm -f "$expected"
432 fi
433
434
435 # check -decodetext (enabled by default)
436 start_test "-decodetext (enabled by default)"
437 cat >"$expected" <<EOF
438 To: recipient@example.com
439 From: sender@example.com
440 Subject: mhfixmsg decode test 1
441 MIME-Version: 1.0
442 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
443
444 ------- =_aaaaaaaaaa0
445 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
446 Content-Disposition: attachment; filename="test4.txt"
447 Content-Transfer-Encoding: 7bit
448
449 This is a text/plain part.
450
451 ------- =_aaaaaaaaaa0--
452 EOF
453
454 cat >"`mhpath new`" <<EOF
455 To: recipient@example.com
456 From: sender@example.com
457 Subject: mhfixmsg decode test 1
458 MIME-Version: 1.0
459 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
460
461 ------- =_aaaaaaaaaa0
462 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
463 Content-Disposition: attachment; filename="test4.txt"
464 Content-Transfer-Encoding: base64
465
466 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
467
468 ------- =_aaaaaaaaaa0--
469 EOF
470
471 run_prog mhfixmsg last -outfile "$actual"
472 check "$expected" "$actual"
473
474
475 # check -decodetext with more complicated content structure
476 start_test "-decodetext with more complicated content structure"
477 cat >$expected <<EOF
478 To: recipient@example.com
479 From: sender@example.com
480 Subject: mhfixmsg decode test 2
481 MIME-Version: 1.0
482 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
483
484 This is additional content before the first subpart of the multipart.
485
486 ------- =_aaaaaaaaaa0
487 Content-Type: multipart/related;
488 type="text/plain"; boundary="subpart__1.1"
489
490 --subpart__1.1
491 Content-Type: text/plain; charset="iso-8859-1"
492 Content-Disposition: attachment; filename="test1.txt"
493
494 This is the first text/plain part, in a subpart.
495
496 --subpart__1.1--
497
498 This is additional content after the last subpart of the multipart.
499
500 ------- =_aaaaaaaaaa0
501 Content-Type: text/plain; charset="iso-8859-1"
502 Content-Disposition: attachment; filename="test2.txt"
503 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
504 Content-Transfer-Encoding: 7bit
505
506 This is the second text/plain part.
507
508 ------- =_aaaaaaaaaa0
509 Content-Type: text/plain; charset="iso-8859-1"
510 Content-Disposition: attachment; filename="test3.txt"
511
512 This is the third text/plain part.
513
514 ------- =_aaaaaaaaaa0
515 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
516 Content-Disposition: attachment; filename="test4.txt"
517 Content-Transfer-Encoding: 7bit
518
519 This is the fourth text/plain part.
520
521 ------- =_aaaaaaaaaa0--
522
523 This is additional content after the last subpart of the multipart.
524 EOF
525
526 cat >"`mhpath new`" <<EOF
527 To: recipient@example.com
528 From: sender@example.com
529 Subject: mhfixmsg decode test 2
530 MIME-Version: 1.0
531 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
532
533 This is additional content before the first subpart of the multipart.
534
535 ------- =_aaaaaaaaaa0
536 Content-Type: multipart/related;
537 type="text/plain"; boundary="subpart__1.1"
538
539 --subpart__1.1
540 Content-Type: text/plain; charset="iso-8859-1"
541 Content-Disposition: attachment; filename="test1.txt"
542
543 This is the first text/plain part, in a subpart.
544
545 --subpart__1.1--
546
547 This is additional content after the last subpart of the multipart.
548
549 ------- =_aaaaaaaaaa0
550 Content-Type: text/plain; charset="iso-8859-1"
551 Content-Disposition: attachment; filename="test2.txt"
552 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
553 Content-Transfer-Encoding: quoted-printable
554
555 This is the second text/plain part.
556
557 ------- =_aaaaaaaaaa0
558 Content-Type: text/plain; charset="iso-8859-1"
559 Content-Disposition: attachment; filename="test3.txt"
560
561 This is the third text/plain part.
562
563 ------- =_aaaaaaaaaa0
564 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
565 Content-Disposition: attachment; filename="test4.txt"
566 Content-Transfer-Encoding: base64
567
568 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
569
570 ------- =_aaaaaaaaaa0--
571
572 This is additional content after the last subpart of the multipart.
573 EOF
574 run_prog mhfixmsg last -outfile "$actual"
575 check "$expected" "$actual"
576
577
578 # check attempted (default, 8 bit) -decodetext of binary text
579 #### Generated the encoded text below with:
580 #### $ printf '\275\262=\274\000\n' | base64
581 start_test "attempted (default, 8 bit) -decodetext of binary text"
582 cat >"`mhpath new`" <<EOF
583 To: recipient@example.com
584 From: sender@example.com
585 Subject: mhfixmsg binary decode test
586 MIME-Version: 1.0
587 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
588
589 ------- =_aaaaaaaaaa0
590 Content-Type: text/plain; charset="UTF-8"; name="nul+square.txt"
591 Content-Transfer-Encoding: base64
592
593 vbI9vAAK
594
595 ------- =_aaaaaaaaaa0--
596 EOF
597
598 cp -p "`mhpath last`" "$expected"
599 run_prog mhfixmsg last
600 check "`mhpath last`" "$expected" 'keep first'
601
602
603 # check for successful decode of a different part with attempted -decodetext
604 # of binary (>998 characters) text
605 start_test "for successful decode of a different part with attempted -decodetext"
606 cat >$expected <<EOF
607 To: recipient@example.com
608 From: sender@example.com
609 Subject: mhfixmsg successful decode of text/plain with failed binary decode
610 MIME-Version: 1.0
611 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
612
613 ------- =_aaaaaaaaaa0
614 Content-Type: text/plain; charset="iso-8859-1"
615 Content-Transfer-Encoding: 7bit
616
617 This is a text plain part
618
619 ------- =_aaaaaaaaaa0
620 Content-Type: text/html; charset="ascii"
621 Content-Transfer-Encoding: base64
622 Content-Disposition: inline
623
624 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
625 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
626 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
627 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
628 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
629 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
630 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
631 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
632 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
633 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
634 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
635 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
636 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
637 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
638 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
639 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
640 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
641 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
642 ICA8L2JvZHk+PC9odG1sPg==
643
644 ------- =_aaaaaaaaaa0--
645 EOF
646
647 cat >"`mhpath new`" <<EOF
648 To: recipient@example.com
649 From: sender@example.com
650 Subject: mhfixmsg successful decode of text/plain with failed binary decode
651 MIME-Version: 1.0
652 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
653
654 ------- =_aaaaaaaaaa0
655 Content-Type: text/plain; charset="iso-8859-1"
656 Content-Transfer-Encoding: base64
657
658 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
659
660 ------- =_aaaaaaaaaa0
661 Content-Type: text/html; charset="ascii"
662 Content-Transfer-Encoding: base64
663 Content-Disposition: inline
664
665 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
666 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
667 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
668 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
669 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
670 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
671 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
672 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
673 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
674 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
675 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
676 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
677 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
678 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
679 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
680 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
681 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
682 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
683 ICA8L2JvZHk+PC9odG1sPg==
684
685 ------- =_aaaaaaaaaa0--
686 EOF
687
688 run_prog mhfixmsg -noreformat last
689 check "`mhpath last`" "$expected" 'keep first'
690
691
692 # check for successful decode of a different part with -decodetext of binary
693 # (>998 characters) text
694 start_test "for successful decode of a different part with -decodetext of binary"
695 cat >$expected <<EOF
696 To: recipient@example.com
697 From: sender@example.com
698 Subject: mhfixmsg successful decode of text/plain with failed binary decode
699 MIME-Version: 1.0
700 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
701 Content-Transfer-Encoding: binary
702
703 ------- =_aaaaaaaaaa0
704 Content-Type: text/plain; charset="iso-8859-1"
705 Content-Transfer-Encoding: 7bit
706
707 This is a text plain part
708
709 ------- =_aaaaaaaaaa0
710 Content-Type: text/html; charset="ascii"
711 Content-Transfer-Encoding: binary
712 Content-Disposition: inline
713
714 <html><head><title>long line</title></head><body>This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. This line is greater than 998 characters in length, so this part should not be decoded. </body></html>
715
716 ------- =_aaaaaaaaaa0--
717 EOF
718
719 run_prog mhfixmsg -noreformat -decodetext binary last
720 check "`mhpath last`" "$expected"
721
722
723 # check -decodetext of binary (containing ASCII NUL) text
724 start_test "-decodetext of binary (containing ASCII NUL) text"
725 printf "%s\275\262=\274\000%s" "To: recipient@example.com
726 From: sender@example.com
727 Subject: mhfixmsg binary decode test
728 MIME-Version: 1.0
729 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
730 Content-Transfer-Encoding: binary
731
732 ------- =_aaaaaaaaaa0
733 Content-Type: text/plain; charset=\"UTF-8\"; name=\"nul+square.txt\"
734 Content-Transfer-Encoding: binary
735
736 " "
737
738 ------- =_aaaaaaaaaa0--
739 " >"$expected"
740 mhfixmsg last -decodetext binary -outfile "$actual"
741 check "$expected" "$actual"
742
743
744 # check that -reformat succeeds when decode of binary text fails
745 start_test "-reformat succeeds when decode of binary text fails"
746 prepare_space >"$expected" <<'EOF'
747 MIME-Version: 1.0
748 Date: Thu, 11 Apr 2013 02:47:08 -0700
749 To: <me@example.com>
750 From: <sender@example.com>
751 Subject: body requires binary encoding
752 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
753
754 ------=_nmh-multipart
755 Content-Type: text/plain; charset="ISO-8859-1"
756 Content-Transfer-Encoding: 7bit
757
758 Mile $0.00
759 Time $78.71
760 State Tax $5.90
761 Vehicle License Fee $1.84
762 State Txn Tax $6.00
763
764 ------=_nmh-multipart
765 Content-Type: text/html; charset="ISO-8859-1"
766 Content-Transfer-Encoding: quoted-printable
767
768 <body>
769 EOF
770
771 cat >"`mhpath new`" <<'EOF'
772 MIME-Version: 1.0
773 Content-Type: text/html; charset="ISO-8859-1"
774 Content-Transfer-Encoding: quoted-printable
775 Date: Thu, 11 Apr 2013 02:47:08 -0700
776 To: <me@example.com>
777 From: <sender@example.com>
778 Subject: body requires binary encoding
779
780 <body>
781 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
782 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
783 =3D"2"><strong>Mile</strong></font></td><td height=3D"3">&nbsp;</td><td ali=
784 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
785 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
786 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
787 height=3D"3">&nbsp;</td><td align=3D"right"><font face=3D"Arial, Helvetica=
788 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
789 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
790 rong>State Tax</strong></font></td><td height=3D"3">&nbsp;</td><td align=3D=
791 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
792 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
793 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
794 nt></td><td height=3D"3">&nbsp;</td><td align=3D"right"><font face=3D"Arial=
795 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
796 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
797 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3">&nbsp;</t=
798 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
799 #333333" size=3D"2">$6.00</font></td></tr>
800
801 </body>
802 </html>
803 EOF
804
805 if [ $can_reformat_texthtml -eq 1 ]; then
806 #### lynx inserts multiple blank lines, so squeeze them.
807 #### Truncate to avoid comparing the html portion because it can
808 #### get reformatted.
809 run_prog mhfixmsg last -outfile - | squeeze_lines | head -22 >"$actual"
810 check "$expected" "$actual" 'ignore space'
811 else
812 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
813 rm -f "$expected"
814 fi
815
816
817 # check -textcharset
818 # Also checks preservation of attributes after one (charset) that is
819 # modified.
820 start_test "-textcharset"
821 cat >"$expected" <<EOF
822 To: recipient@example.com
823 From: sender@example.com
824 Subject: mhfixmsg textcharset test
825 MIME-Version: 1.0
826 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
827 Content-Transfer-Encoding: 8bit
828
829 ------- =_aaaaaaaaaa0
830 Content-Type: text/plain; charset="utf-8"; name="square.txt"
831 Content-Disposition: attachment; filename="square.txt"
832 Content-Transfer-Encoding: 8bit
833
834 ½²=¼
835
836 ------- =_aaaaaaaaaa0--
837 EOF
838
839 #### Generated the encoded text below with:
840 #### $ printf '\275\262=\274\n' | base64
841 cat >"`mhpath new`" <<EOF
842 To: recipient@example.com
843 From: sender@example.com
844 Subject: mhfixmsg textcharset test
845 MIME-Version: 1.0
846 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
847
848 ------- =_aaaaaaaaaa0
849 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
850 Content-Disposition: attachment; filename="square.txt"
851 Content-Transfer-Encoding: base64
852
853 vbI9vAo=
854
855 ------- =_aaaaaaaaaa0--
856 EOF
857
858 if test "$ICONV_ENABLED" -eq 1; then
859 run_prog mhfixmsg last -textcharset utf-8 -outfile "$actual" 2>&1
860 check "$expected" "$actual"
861 else
862 echo "$0: skipping -textcharset check because nmh was built without iconv"
863 rm -f "$expected"
864 fi
865
866
867 # check -nofixboundary
868 start_test "-nofixboundary"
869 cat >"$expected" <<EOF
870 EOF
871
872 cat >"`mhpath new`" <<EOF
873 Date: Fri, 13 May 2011 08:21:12 -0500
874 Content-Type: multipart/alternative;
875 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
876 Content-Transfer-Encoding: 8bit
877 MIME-Version: 1.0
878 From: <sender@example.com>
879 To: <recipient@example.com>
880 Subject: mhfixmsg bad boundary test
881
882 This is a multi-part message in MIME format.
883
884 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
885 Content-Type: text/plain
886
887 The boundaries of this part don't match the header boundary.
888
889 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
890 EOF
891
892 cp -p "`mhpath last`" "`mhpath new`"
893
894 run_test 'mhfixmsg last -nofixboundary' ''
895 check "$MH_TEST_DIR"/Mail/inbox/18 "$MH_TEST_DIR"/Mail/inbox/19 'keep first'
896
897
898 # check that message is not output when fed through stdin (without -outfile)
899 start_test "message is not output when fed through stdin"
900 run_prog mhfixmsg -file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
901 check "$expected" "$actual"
902 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
903 "$actual.err" >/dev/null; then
904 rm -f "$actual.err"
905 else
906 echo "$0: test failed, output is in $actual.err."
907 failed=`expr ${failed:-0} + 1`
908 fi
909
910
911 # check fixup of erroneous boundary in multipart (-fixboundary,
912 # enabled by default)
913 # check -verbose
914 start_test "fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
915 cat >"$expected" <<EOF
916 Date: Fri, 13 May 2011 08:21:12 -0500
917 Content-Type: multipart/alternative;
918 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
919 Content-Transfer-Encoding: 8bit
920 MIME-Version: 1.0
921 From: <sender@example.com>
922 To: <recipient@example.com>
923 Subject: mhfixmsg bad boundary test
924
925 This is a multi-part message in MIME format.
926
927 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
928 Content-Type: text/plain
929
930 The boundaries of this part don't match the header boundary.
931
932 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
933 EOF
934
935 run_test 'mhfixmsg last -outfile '"$actual"' -verbose' \
936 "mhfixmsg: 18, fix multipart boundary"
937 check "$expected" "$actual"
938
939
940 # check that message is not modified when -fixboundary fails
941 start_test "message is not modified when -fixboundary fails"
942 cat >"`mhpath new`" <<EOF
943 Date: Fri, 13 May 2011 08:21:12 -0500
944 Content-Type: multipart/alternative;
945 boundary="----=_ NextPart_000_1781A17_01CC1147.81E9467A"
946 Content-Transfer-Encoding: 8bit
947 MIME-Version: 1.0
948 From: <sender@example.com>
949 To: <recipient@example.com>
950 Subject: mhfixmsg bad boundary test
951
952 This is a multi-part message in MIME format.
953
954 ------=_ NextPart_000_1781A1A_01CC1147.81EBA8D4
955 Content-Type: text/plain
956
957 The boundary below doesn't match the header boundary.
958
959 ------=_
960 NextPart_000_1781A1A_01CC1147.81EBA8D4--
961 EOF
962
963 cp -p "`mhpath last`" "$expected"
964 run_test "mhfixmsg last -outfile $actual" ''
965 check "$expected" "$actual"
966
967
968 # check that text/plain part is not added to text/html in multipart/related
969 # when it shouldn't be
970 start_test "text/plain part is not added to text/html in multipart/related when it shouldn't be"
971 cat >"`mhpath new`" <<EOF
972 MIME-Version: 1.0
973 Date: Tue, 26 Feb 2013 18:07:20 -0600
974 Subject: multipart/related, not /alternative
975 Content-Type: multipart/related;
976 type="text/html"; boundary="----=_Part_90310_101292502.1"
977
978 ------=_Part_90310_101292502.1
979 Content-Type: text/html; charset="us-ascii"
980 Content-Transfer-Encoding: 7bit
981
982 <html><head>
983 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
984 <title>HTML Content</title>
985 </head>
986 <body>
987 This is the real content.
988 </body>
989 </html>
990
991 ------=_Part_90310_101292502.1
992 Content-Type: text/plain; charset="us-ascii"
993 Content-Transfer-Encoding: 7bit
994
995 Your email client does not support HTML messages
996
997 ------=_Part_90310_101292502.1--
998 EOF
999
1000 cp -p "`mhpath last`" "$expected"
1001
1002 if [ $can_reformat_texthtml -eq 1 ]; then
1003 #### lynx inserts multiple blank lines, so squeeze them.
1004 run_prog mhfixmsg last -outfile - | squeeze_lines >"$actual"
1005 check "$expected" "$actual" 'ignore space'
1006 else
1007 rm -f "$expected"
1008 fi
1009
1010
1011 # check that text/plain part is added to text/html in multipart/related
1012 # when it should be
1013 start_test "text/plain part is added to text/html in multipart/related when it should be"
1014 cat >"$expected" <<EOF
1015 MIME-Version: 1.0
1016 Date: Tue, 26 Feb 2013 18:07:20 -0600
1017 Subject: multipart/related, not /alternative
1018 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
1019
1020 ------=_Part_90310_101292502.1
1021 Content-Type: text/plain; charset="us-ascii"
1022 Content-Transfer-Encoding: 7bit
1023
1024 This is the real content.
1025
1026 ------=_Part_90310_101292502.1
1027 Content-Type: text/html; charset="us-ascii"
1028 Content-Transfer-Encoding: 7bit
1029
1030 <html><head>
1031 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1032 <title>HTML Content</title>
1033 </head>
1034 <body>
1035 This is the real content.
1036 </body>
1037 </html>
1038
1039 ------=_Part_90310_101292502.1--
1040 EOF
1041
1042 cat >"`mhpath new`" <<EOF
1043 MIME-Version: 1.0
1044 Date: Tue, 26 Feb 2013 18:07:20 -0600
1045 Subject: multipart/related, not /alternative
1046 Content-Type: multipart/related;
1047 type="text/html"; boundary="----=_Part_90310_101292502.1"
1048
1049 ------=_Part_90310_101292502.1
1050 Content-Type: text/html; charset="us-ascii"
1051 Content-Transfer-Encoding: 7bit
1052
1053 <html><head>
1054 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
1055 <title>HTML Content</title>
1056 </head>
1057 <body>
1058 This is the real content.
1059 </body>
1060 </html>
1061
1062 ------=_Part_90310_101292502.1--
1063 EOF
1064
1065 if [ $can_reformat_texthtml -eq 1 ]; then
1066 #### lynx inserts multiple blank lines, so squeeze them.
1067 run_prog mhfixmsg last -outfile - | squeeze_lines >"$actual"
1068 check "$expected" "$actual" 'ignore space'
1069 else
1070 rm -f "$expected"
1071 fi
1072
1073
1074 # check handling of rfc822 message type
1075 # also, checks -fixboundary
1076 start_test "handling of rfc822 message type"
1077 cat >"$expected" <<EOF
1078 From: Test <test@example.com>
1079 To: Some User <user@example.com>
1080 Date: Fri, 29 Sep 2006 00:00:00
1081 Message-Id: @test.nmh
1082 Subject: message with message/rfc822 attachment
1083 MIME-Version: 1.0
1084 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1085
1086 and some garbage before the attachment
1087
1088 ------- =_aaaaaaaaaa0
1089 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1090 Content-Description: 1552
1091 Content-Disposition: attachment; filename="1552"
1092
1093 From: Test <test@example.com>
1094 To: <another_user@example.com>
1095 Date: Thu, 28 Sep 2006 00:00:00
1096 Message-Id: @test.nmh
1097 Subject: message/rfc822 attachment
1098
1099 This is an RFC-822 message.
1100
1101 ------- =_aaaaaaaaaa0--
1102
1103 and some garbage at the end
1104 EOF
1105
1106 cat >"`mhpath new`" <<EOF
1107 From: Test <test@example.com>
1108 To: Some User <user@example.com>
1109 Date: Fri, 29 Sep 2006 00:00:00
1110 Message-Id: @test.nmh
1111 Subject: message with message/rfc822 attachment
1112 MIME-Version: 1.0
1113 Content-Type: multipart/mixed; boundary="----- =badboundary"
1114
1115 and some garbage before the attachment
1116
1117 ------- =_aaaaaaaaaa0
1118 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1119 Content-Description: 1552
1120 Content-Disposition: attachment; filename="1552"
1121
1122 From: Test <test@example.com>
1123 To: <another_user@example.com>
1124 Date: Thu, 28 Sep 2006 00:00:00
1125 Message-Id: @test.nmh
1126 Subject: message/rfc822 attachment
1127
1128 This is an RFC-822 message.
1129
1130 ------- =_aaaaaaaaaa0--
1131
1132 and some garbage at the end
1133 EOF
1134
1135 run_test 'mhfixmsg last -outfile '"$actual" ''
1136 check "$expected" "$actual"
1137
1138
1139 # check not stripping of CRs from ASCII text context (default)
1140 start_test "not stripping of CRs from ASCII text context (default)"
1141 cat >"$expected" <<EOF
1142 MIME-Version: 1.0
1143 From: sender@example.com
1144 To: recipient@example.com
1145 Subject: message with CR's
1146 Date: Mon, 29 Apr 2013 11:51:45 -0400
1147
1148 There are two CR-LF pairs at the end of this sentence.
1149
1150 EOF
1151
1152 cat >"`mhpath new`" <<'EOF'
1153 MIME-Version: 1.0
1154 From: sender@example.com
1155 To: recipient@example.com
1156 Subject: message with CR's
1157 Date: Mon, 29 Apr 2013 11:51:45 -0400
1158
1159 There are two CR-LF pairs at the end of this sentence.
1160
1161 EOF
1162
1163 run_prog mhfixmsg last -outfile "$actual"
1164 check "$expected" "$actual"
1165
1166
1167 # check stripping of CRs from ASCII text context
1168 start_test "stripping of CRs from ASCII text context"
1169 cat >"$expected" <<EOF
1170 MIME-Version: 1.0
1171 From: sender@example.com
1172 To: recipient@example.com
1173 Subject: message with CR's
1174 Date: Mon, 29 Apr 2013 11:51:45 -0400
1175
1176 There were two CR-LF pairs at the end of this sentence.
1177
1178 EOF
1179
1180 cat >"`mhpath new`" <<'EOF'
1181 MIME-Version: 1.0
1182 From: sender@example.com
1183 To: recipient@example.com
1184 Subject: message with CR's
1185 Date: Mon, 29 Apr 2013 11:51:45 -0400
1186
1187 There were two CR-LF pairs at the end of this sentence.
1188
1189 EOF
1190
1191 run_prog mhfixmsg last -outfile "$actual" -nocrlflinebreaks
1192 check "$expected" "$actual"
1193
1194
1195 # check -replacetextplain
1196 start_test "-replacetextplain"
1197 prepare_space >"$expected" <<EOF
1198 To: recipient@example.com
1199 From: sender@example.com
1200 Subject: mhfixmsg replacement of bad text/plain part test
1201 MIME-Version: 1.0
1202 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1203
1204 ------=_Part_876302
1205 Content-Type: text/plain; charset="UTF-8"
1206 Content-Transfer-Encoding: 7bit
1207
1208 Yes, the text/plain part really was empty.
1209
1210 ------=_Part_876302
1211 Content-Type: text/html; charset="UTF-8"
1212 Content-Disposition: inline
1213
1214 <html><head>
1215 <title>eticket</title>
1216 </head>
1217 <body>
1218 Yes, the text/plain part really was empty.
1219 </body>
1220 </html>
1221
1222 ------=_Part_876302--
1223 EOF
1224
1225 cat >"`mhpath new`" <<'EOF'
1226 To: recipient@example.com
1227 From: sender@example.com
1228 Subject: mhfixmsg replacement of bad text/plain part test
1229 MIME-Version: 1.0
1230 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1231
1232 ------=_Part_876302
1233 Content-Type: text/plain; charset="iso-8859-15"
1234 Content-Transfer-Encoding: 7bit
1235 Content-Disposition: inline
1236
1237
1238
1239 ------=_Part_876302
1240 Content-Type: text/html; charset="UTF-8"
1241 Content-Disposition: inline
1242
1243 <html><head>
1244 <title>eticket</title>
1245 </head>
1246 <body>
1247 Yes, the text/plain part really was empty.
1248 </body>
1249 </html>
1250
1251 ------=_Part_876302--
1252 EOF
1253
1254 if [ $can_reformat_texthtml -eq 1 ]; then
1255 #### lynx inserts multiple blank lines, so squeeze them.
1256 run_prog mhfixmsg last -replacetextplain -outfile - | \
1257 squeeze_lines > "$actual"
1258 check "$expected" "$actual" 'ignore space'
1259 else
1260 rm -f "$expected"
1261 fi
1262
1263
1264 # check -noreplacetextplain
1265 start_test "-noreplacetextplain"
1266 cat >"$expected" <<EOF
1267 To: recipient@example.com
1268 From: sender@example.com
1269 Subject: mhfixmsg replacement of bad text/plain part test
1270 MIME-Version: 1.0
1271 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1272
1273 ------=_Part_876302
1274 Content-Type: text/plain; charset="iso-8859-15"
1275 Content-Transfer-Encoding: 7bit
1276 Content-Disposition: inline
1277
1278
1279
1280 ------=_Part_876302
1281 Content-Type: text/html; charset="UTF-8"
1282 Content-Disposition: inline
1283
1284 <html><head>
1285 <title>eticket</title>
1286 </head>
1287 <body>
1288 Yes, the text/plain part really was empty.
1289 </body>
1290 </html>
1291
1292 ------=_Part_876302--
1293 EOF
1294
1295 run_prog mhfixmsg last -replacetextplain -noreplacetextplain -outfile "$actual"
1296 check "$expected" "$actual"
1297
1298
1299 # check removal of extraneous trailing semicolon from header parameter list
1300 start_test "removal of extraneous trailing semicolon from header parameter list"
1301 cat >"$expected" <<EOF
1302 To: recipient@example.com
1303 Subject: test
1304 From: sender@example.com
1305 MIME-Version: 1.0
1306 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1307
1308 ------- =_aaaaaaaaaa0
1309 Content-Type: text/plain; charset="us-ascii"
1310
1311 test
1312
1313 ------- =_aaaaaaaaaa0
1314 Content-Type: text/plain; charset="us-ascii";
1315 name="DATE"
1316 Content-Description: check folded headers, with and without trailing semicolon
1317 Content-Disposition: attachment;
1318 filename="DATE"
1319
1320 14 April 2014
1321
1322 ------- =_aaaaaaaaaa0--
1323 EOF
1324
1325 cat >"`mhpath new`" <<EOF
1326 To: recipient@example.com
1327 Subject: test
1328 From: sender@example.com
1329 MIME-Version: 1.0
1330 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1331
1332 ------- =_aaaaaaaaaa0
1333 Content-Type: text/plain; charset="us-ascii";
1334
1335 test
1336
1337 ------- =_aaaaaaaaaa0
1338 Content-Type: text/plain; charset="us-ascii";
1339 name="DATE"
1340 Content-Description: check folded headers, with and without trailing semicolon
1341 Content-Disposition: attachment;
1342 filename="DATE";
1343
1344 14 April 2014
1345
1346 ------- =_aaaaaaaaaa0--
1347 EOF
1348 run_test 'mhfixmsg last -outfile '"$actual" ''
1349 check "$expected" "$actual"
1350
1351
1352 # check rmmproc
1353 start_test "rmmproc"
1354 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1355 mv "$1" "$1.backup"
1356 EOF
1357 chmod a+x "${MH_TEST_DIR}/Mail/rmmproc"
1358 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1359 cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
1360
1361 run_test 'mhfixmsg 16' ''
1362 check "${MH_TEST_DIR}/Mail/inbox/16.backup" \
1363 "${MH_TEST_DIR}/Mail/inbox/16.original"
1364
1365
1366 # check -normmproc
1367 start_test "-normmproc"
1368 cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
1369
1370 run_test 'mhfixmsg 21 -normmproc'
1371 check "${MH_TEST_DIR}/Mail/inbox/22" \
1372 "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
1373
1374
1375 # check -rmmproc
1376 start_test "-rmmproc"
1377 run_test 'mhfixmsg 21 -rmmproc true'
1378 if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
1379 echo check of mhfixmsg -rmmproc FAILED, should not have created backup file
1380 failed=`expr ${failed:-0} + 1`
1381 fi
1382
1383
1384 # check -fixtype
1385 start_test "-fixtype"
1386 cat >"$expected" <<EOF
1387 To: recipient@example.com
1388 From: sender@example.com
1389 Subject: mhfixmsg with incorrect Content-Type
1390 MIME-Version: 1.0
1391 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1392
1393 ------- =_aaaaaaaaaa0
1394 Content-Type: text/plain; name="plaintext.txt"
1395
1396 this is plain text
1397
1398 ------- =_aaaaaaaaaa0--
1399 EOF
1400
1401 cat >"`mhpath new`" <<EOF
1402 To: recipient@example.com
1403 From: sender@example.com
1404 Subject: mhfixmsg with incorrect Content-Type
1405 MIME-Version: 1.0
1406 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1407
1408 ------- =_aaaaaaaaaa0
1409 Content-Type: application/octet-stream; name="plaintext.txt"
1410
1411 this is plain text
1412
1413 ------- =_aaaaaaaaaa0--
1414 EOF
1415
1416 mhfixmsg -fixtype application/octet-stream last
1417 check "$expected" "`mhpath last`"
1418
1419
1420 # check default -decodetypes
1421 start_test "default -decodetypes"
1422 cat >$expected <<EOF
1423 To: recipient@example.com
1424 From: sender@example.com
1425 Subject: mhfixmsg decode test 3
1426 MIME-Version: 1.0
1427 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1428
1429 ------- =_aaaaaaaaaa0
1430 Content-Type: text/plain; charset="iso-8859-1"
1431 Content-Disposition: attachment; filename="test1.txt"
1432 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1433 Content-Transfer-Encoding: 7bit
1434
1435 This is the text/plain part.
1436
1437 ------- =_aaaaaaaaaa0
1438 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1439 Content-Disposition: attachment; filename="test2.txt"
1440 Content-Transfer-Encoding: 7bit
1441
1442 <html>
1443 <head>
1444 This was the text/html part.
1445 </head>
1446 </body>
1447 </html>
1448
1449 ------- =_aaaaaaaaaa0--
1450 EOF
1451
1452 cat >"`mhpath new`" <<EOF
1453 To: recipient@example.com
1454 From: sender@example.com
1455 Subject: mhfixmsg decode test 3
1456 MIME-Version: 1.0
1457 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1458
1459 ------- =_aaaaaaaaaa0
1460 Content-Type: text/plain; charset="iso-8859-1"
1461 Content-Disposition: attachment; filename="test1.txt"
1462 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1463 Content-Transfer-Encoding: quoted-printable
1464
1465 This is the text/plain part.
1466
1467 ------- =_aaaaaaaaaa0
1468 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1469 Content-Disposition: attachment; filename="test2.txt"
1470 Content-Transfer-Encoding: base64
1471
1472 PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
1473 Ym9keT4KPC9odG1sPgo=
1474
1475 ------- =_aaaaaaaaaa0--
1476 EOF
1477 run_prog mhfixmsg last -outfile "$actual" -noreformat
1478 check "$expected" "$actual"
1479
1480
1481 # check -decodetypes text/plain
1482 start_test "-decodetypes text/plain"
1483 cat >$expected <<EOF
1484 To: recipient@example.com
1485 From: sender@example.com
1486 Subject: mhfixmsg decode test 4
1487 MIME-Version: 1.0
1488 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1489
1490 ------- =_aaaaaaaaaa0
1491 Content-Type: text/plain; charset="iso-8859-1"
1492 Content-Disposition: attachment; filename="test1.txt"
1493 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1494 Content-Transfer-Encoding: 7bit
1495
1496 This is the text/plain part.
1497
1498 ------- =_aaaaaaaaaa0
1499 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1500 Content-Disposition: attachment; filename="test2.txt"
1501 Content-Transfer-Encoding: base64
1502
1503 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1504 CjwvYm9keT4NCjwvaHRtbD4NCg==
1505
1506 ------- =_aaaaaaaaaa0--
1507 EOF
1508
1509 cat >"`mhpath new`" <<EOF
1510 To: recipient@example.com
1511 From: sender@example.com
1512 Subject: mhfixmsg decode test 4
1513 MIME-Version: 1.0
1514 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1515
1516 ------- =_aaaaaaaaaa0
1517 Content-Type: text/plain; charset="iso-8859-1"
1518 Content-Disposition: attachment; filename="test1.txt"
1519 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1520 Content-Transfer-Encoding: quoted-printable
1521
1522 This is the text/plain part.
1523
1524 ------- =_aaaaaaaaaa0
1525 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1526 Content-Disposition: attachment; filename="test2.txt"
1527 Content-Transfer-Encoding: base64
1528
1529 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1530 CjwvYm9keT4NCjwvaHRtbD4NCg==
1531
1532 ------- =_aaaaaaaaaa0--
1533 EOF
1534 run_prog mhfixmsg last -outfile "$actual" -decodetypes text/plain -noreformat
1535 check "$expected" "$actual"
1536
1537
1538 # check -decodetypes attachment/ics
1539 start_test "-decodetypes attachment/ics"
1540 cat >$expected <<EOF
1541 To: recipient@example.com
1542 From: sender@example.com
1543 Subject: mhfixmsg decode test 5
1544 MIME-Version: 1.0
1545 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1546
1547 ------- =_aaaaaaaaaa0
1548 Content-Type: text/plain; charset="iso-8859-1"
1549 Content-Disposition: attachment; filename="test1.txt"
1550 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1551 Content-Transfer-Encoding: 7bit
1552
1553 This is the text/plain part.
1554
1555 ------- =_aaaaaaaaaa0
1556 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1557 Content-Disposition: attachment; filename="invite.ics"
1558 Content-Transfer-Encoding: 7bit
1559
1560 BEGIN:VCALENDAR
1561 VERSION:2.0
1562 PRODID:test-mhical
1563 BEGIN:VEVENT
1564 DTSTAMP:20150101T162400Z
1565 DTSTART:20150105T160000
1566 DTEND:20150105T163000
1567 SUMMARY:4 pm meeting
1568 END:VEVENT
1569 END:VCALENDAR
1570
1571 ------- =_aaaaaaaaaa0--
1572 EOF
1573
1574 cat >"`mhpath new`" <<EOF
1575 To: recipient@example.com
1576 From: sender@example.com
1577 Subject: mhfixmsg decode test 5
1578 MIME-Version: 1.0
1579 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1580
1581 ------- =_aaaaaaaaaa0
1582 Content-Type: text/plain; charset="iso-8859-1"
1583 Content-Disposition: attachment; filename="test1.txt"
1584 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1585 Content-Transfer-Encoding: quoted-printable
1586
1587 This is the=
1588 text/plain part.
1589
1590 ------- =_aaaaaaaaaa0
1591 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1592 Content-Disposition: attachment; filename="invite.ics"
1593 Content-Transfer-Encoding: base64
1594
1595 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1596 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1597 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1598 CkVORDpWQ0FMRU5EQVINCg==
1599
1600 ------- =_aaaaaaaaaa0--
1601 EOF
1602 run_prog mhfixmsg last -outfile "$actual" -noreformat
1603 check "$expected" "$actual"
1604
1605
1606 # check -decodetypes attachment/ics and -nocrlflinebreaks
1607 start_test "-decodetypes attachment/ics and -nocrlflinebreaks"
1608 cat >$expected <<EOF
1609 To: recipient@example.com
1610 From: sender@example.com
1611 Subject: mhfixmsg decode test 5
1612 MIME-Version: 1.0
1613 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1614
1615 ------- =_aaaaaaaaaa0
1616 Content-Type: text/plain; charset="iso-8859-1"
1617 Content-Disposition: attachment; filename="test1.txt"
1618 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1619 Content-Transfer-Encoding: 7bit
1620
1621 This is the text/plain part.
1622
1623 ------- =_aaaaaaaaaa0
1624 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1625 Content-Disposition: attachment; filename="invite.ics"
1626 Content-Transfer-Encoding: 7bit
1627
1628 BEGIN:VCALENDAR
1629 VERSION:2.0
1630 PRODID:test-mhical
1631 BEGIN:VEVENT
1632 DTSTAMP:20150101T162400Z
1633 DTSTART:20150105T160000
1634 DTEND:20150105T163000
1635 SUMMARY:4 pm meeting
1636 END:VEVENT
1637 END:VCALENDAR
1638
1639 ------- =_aaaaaaaaaa0--
1640 EOF
1641
1642 cat >"`mhpath new`" <<EOF
1643 To: recipient@example.com
1644 From: sender@example.com
1645 Subject: mhfixmsg decode test 5
1646 MIME-Version: 1.0
1647 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1648
1649 ------- =_aaaaaaaaaa0
1650 Content-Type: text/plain; charset="iso-8859-1"
1651 Content-Disposition: attachment; filename="test1.txt"
1652 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1653 Content-Transfer-Encoding: quoted-printable
1654
1655 This is the=
1656 text/plain part.
1657
1658 ------- =_aaaaaaaaaa0
1659 Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
1660 Content-Disposition: attachment; filename="invite.ics"
1661 Content-Transfer-Encoding: base64
1662
1663 QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
1664 RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
1665 CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
1666 CkVORDpWQ0FMRU5EQVINCg==
1667
1668 ------- =_aaaaaaaaaa0--
1669 EOF
1670 run_prog mhfixmsg last -outfile "$actual" -nocrlflinebreaks -noreformat
1671 check "$expected" "$actual"
1672
1673
1674 # check that input is passed through to output when there's a parse error
1675 # (the charset string is missing its closing quote) with -outfile
1676 start_test "input is passed through to output when there's a parse error"
1677 cat >"$expected.err" <<EOF
1678 mhfixmsg: invalid quoted-string in message 31's Content-Type: field
1679 (parameter charset)
1680 mhfixmsg: unable to parse message 31
1681 EOF
1682
1683 cat >"`mhpath new`" <<EOF
1684 To: recipient@example.com
1685 From: sender@example.com
1686 Subject: mhfixmsg pass through on parse error
1687 MIME-Version: 1.0
1688 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1689
1690 ------- =_aaaaaaaaaa0
1691 Content-Type: text/plain; charset="iso-8859-1
1692 Content-Disposition: attachment; filename="test1.txt"
1693 Content-Transfer-Encoding: quoted-printable
1694
1695 This is the=
1696 text/plain part.
1697
1698 ------- =_aaaaaaaaaa0--
1699 EOF
1700 set +e
1701 run_prog mhfixmsg last -outfile "$actual" 2>"$actual.err"
1702 set -e
1703 #### Expected output is identical to the input message.
1704 check "`mhpath last`" "$actual" 'keep first'
1705 check "$expected.err" "$actual.err"
1706
1707
1708 # check that input is passed through to output when there's a parse error
1709 # (the charset string is missing its closing quote) with -outfile, and
1710 # input from stdin. Don't check err output, because it contains the name
1711 # of a tmp file. It's similar to that of the previous check.
1712 start_test "input is passed through to output when there's a parse error"
1713 set +e
1714 run_prog mhfixmsg -file - -outfile - <`mhpath last` >"$actual" 2>/dev/null
1715 set -e
1716 #### Expected output is identical to the input message.
1717 check "`mhpath last`" "$actual" 'keep first'
1718
1719
1720 start_test "pass through message with relative folder path with parse error"
1721 #### Factor out leading portion of current folder path and make it relative.
1722 pwd=`pwd`
1723 set +e
1724 run_prog mhfixmsg +./`mhpath | sed "s%^$pwd/%%"` last -out - >"$actual" 2>/dev/null
1725 set -e
1726 folder -f +inbox >/dev/null
1727 #### Expected output is identical to the input message.
1728 check "`mhpath last`" "$actual"
1729
1730
1731 start_test "fix RFC 2047 encoded header parameters"
1732 #### Also, add C-T-E:8bit to the message headers.
1733 cat >"$expected" <<EOF
1734 To: recipient@example.com
1735 From: sender@example.com
1736 Date: Wed, 28 Sep 2016 11:24:28 -0400
1737 Subject: invalid header parameter encoding
1738 MIME-Version: 1.0
1739 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1740 Content-Transfer-Encoding: 8bit
1741
1742 --001a114dd3e8fe9c56053d92f414
1743 Content-Type: text/plain; charset=UTF-8
1744
1745 This is a test.
1746
1747 --001a114dd3e8fe9c56053d92f414
1748 Content-Type: text/plain; charset="UTF-8"; name*=UTF-8''test%C3%B8.txt
1749 Content-Disposition: attachment; filename*=UTF-8''test%C3%B8.txt
1750 Content-Transfer-Encoding: 8bit
1751
1752 This is the first text/plain part, in a subpart. The file name
1753 is testø.txt.
1754
1755 --001a114dd3e8fe9c56053d92f414--
1756 EOF
1757
1758 cat >"`mhpath new`" <<EOF
1759 To: recipient@example.com
1760 From: sender@example.com
1761 Date: Wed, 28 Sep 2016 11:24:28 -0400
1762 Subject: invalid header parameter encoding
1763 MIME-Version: 1.0
1764 Content-Type: multipart/mixed; boundary=001a114dd3e8fe9c56053d92f414
1765
1766 --001a114dd3e8fe9c56053d92f414
1767 Content-Type: text/plain; charset=UTF-8
1768
1769 This is a test.
1770
1771 --001a114dd3e8fe9c56053d92f414
1772 Content-Type: text/plain; charset=UTF-8; name="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1773 Content-Disposition: attachment; filename="=?UTF-8?B?dGVzdMO4LnR4dA==?="
1774 Content-Transfer-Encoding: 8bit
1775
1776 This is the first text/plain part, in a subpart. The file name
1777 is testø.txt.
1778
1779 --001a114dd3e8fe9c56053d92f414--
1780 EOF
1781 run_prog mhfixmsg -file - -outfile - <`mhpath last` >"$actual" 2>/dev/null
1782 check "$expected" "$actual"
1783
1784
1785 # make sure there are no tmp files left over
1786 find "$MH_TEST_DIR/Mail" \( -name 'mhfix*' -o -name ',mhfix*' \) -print \
1787 >"$actual"
1788 cat >"$expected" <<EOF
1789 EOF
1790
1791 check "$expected" "$actual"
1792
1793 finish_test
1794 exit $failed