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