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