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