]> diplodocus.org Git - nmh/blob - test/mhfixmsg/test-mhfixmsg
Added check for successful decode of a different part with
[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 #### Make sure that html-to-text conversion is what we expect.
20 require_locale en_US.utf-8 en_US.utf8
21 LC_ALL=en_US.UTF-8; export LC_ALL
22
23 expected="$MH_TEST_DIR/test-mhfixmsg$$.expected"
24 expected_err="$MH_TEST_DIR/test-mhfixmsg$$.expected_err"
25 actual="$MH_TEST_DIR/test-mhfixmsg$$.actual"
26 actual_err="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
27
28 mhn_defaults="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
29
30 if grep mhfixmsg-format-text/html "${mhn_defaults}" \
31 >/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 cat >"$expected" <<EOF
50 Usage: mhfixmsg [+folder] [msgs] [switches]
51 switches are:
52 -decodetext 8bit|7bit
53 -nodecodetext
54 -decodetypes
55 -[no]textcharset
56 -[no]reformat
57 -[no]replacetextplain
58 -[no]fixboundary
59 -[no]fixcte
60 -fixtype mimetype
61 -file file
62 -outfile file
63 -rmmproc program
64 -normmproc
65 -[no]changecur
66 -[no]verbose
67 -version
68 -help
69 EOF
70
71 run_prog mhfixmsg -help >"$actual" 2>&1
72 check "$expected" "$actual"
73
74
75 # check -version
76 case `mhfixmsg -version` in
77 mhfixmsg\ --*) ;;
78 *) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
79 failed=`expr ${failed:-0} + 1`;;
80 esac
81
82
83 # check that non-MIME messages aren't modified
84 # check -outfile
85 run_test 'mhfixmsg first -outfile '"$actual" ''
86 check "`mhpath first`" "$actual" 'keep first'
87
88
89 # check that non-MIME messages with no bodies aren't modified
90 # check -outfile
91 cat >`mhpath new` <<EOF
92 From: Test <test@example.com>
93 To: Some User <user@example.com>
94 Date: Fri, 29 Sep 2006 00:00:00
95 Message-Id: @test.nmh
96 Subject: message with no body
97 EOF
98
99 run_test 'mhfixmsg last -outfile '"$actual" ''
100 check "`mhpath last`" "$actual"
101
102
103 # check -nofixcte
104 cat >"$MH_TEST_DIR"/Mail/inbox/11 <<EOF
105 From: Anon
106 To: Mailinglist
107 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
108 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
109 MIME-Version: 1.0
110 Content-Type: MULTIPART/MIXED;
111 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
112 Content-Transfer-Encoding: QUOTED-PRINTABLE
113
114 This message is in MIME format. The first part should be readable
115 text,
116 while the remaining parts are likely unreadable without MIME-aware
117 tools.
118
119 ------=_NextPart_000_0000_00000000.00000000
120 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
121 Content-Transfer-Encoding: 8BIT
122
123 Some text in swedish.
124
125 Varf=C3=B6r inte anv=C3=A4nda...
126
127 ------=_NextPart_000_0000_00000000.00000000--
128
129 And some text after the last part.
130 EOF
131
132 cp -p "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/12
133
134 run_test 'mhfixmsg last -nofixcte' ''
135 check "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/12 'keep first'
136
137
138 # check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
139 # check -verbose
140 cat >"$expected" <<EOF
141 From: Anon
142 To: Mailinglist
143 Subject: =?ISO-8859-15?Q?Re=3A_H=E5lla_linuxsystem_uppdaterade?=
144 User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
145 MIME-Version: 1.0
146 Content-Type: MULTIPART/MIXED;
147 BOUNDARY="----=_NextPart_000_0000_00000000.00000000"
148 Nmh-REPLACED-INVALID-Content-Transfer-Encoding: QUOTED-PRINTABLE
149 Content-Transfer-Encoding: 8bit
150
151 This message is in MIME format. The first part should be readable
152 text,
153 while the remaining parts are likely unreadable without MIME-aware
154 tools.
155
156 ------=_NextPart_000_0000_00000000.00000000
157 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15
158 Content-Transfer-Encoding: 8BIT
159
160 Some text in swedish.
161
162 Varf=C3=B6r inte anv=C3=A4nda...
163
164 ------=_NextPart_000_0000_00000000.00000000--
165
166 And some text after the last part.
167 EOF
168
169 run_test 'mhfixmsg last -outfile '"$actual"' -verbose' \
170 "mhfixmsg: 11, replace Content-Transfer-Encoding of \
171 QUOTED-PRINTABLE with 8 bit"
172 check "$expected" "$actual" 'keep first'
173
174
175 # check with no options: checks backup
176 cp "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/11.original
177 folder last >/dev/null
178 run_test 'mhfixmsg' ''
179 check "$expected" "$MH_TEST_DIR"/Mail/inbox/11 'keep first'
180 cp "$MH_TEST_DIR"/Mail/inbox/11.original "$MH_TEST_DIR"/Mail/inbox/11
181 check "$MH_TEST_DIR"/Mail/inbox/,11 "$MH_TEST_DIR"/Mail/inbox/11.original
182
183
184 # check backup with -file
185 cp "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/11.original
186 folder last >/dev/null
187 run_test 'mhfixmsg -file '"$MH_TEST_DIR"/Mail/inbox/11 ''
188 check "$MH_TEST_DIR"/Mail/inbox/11 "$expected" 'keep first'
189 check "$MH_TEST_DIR"/Mail/inbox/,11 "$MH_TEST_DIR"/Mail/inbox/11.original
190
191
192 # check -reformat (enabled by default): addition of text/plain part
193 # to solitary text/html part
194 #
195 prepare_space >"$expected" <<EOF
196 MIME-Version: 1.0
197 From: sender@example.com
198 To: bonquiqui@example.com
199 Subject: rue
200 Date: Sat, 26 Jan 2013 17:37:53 -0500
201 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
202
203 ------=_nmh-multipart
204 Content-Type: text/plain; charset="Windows-1252"
205 Content-Transfer-Encoding: 8bit
206
207 Need to go! Need ... to ... go!
208
209 ------=_nmh-multipart
210 Content-Type: text/html; charset="Windows-1252"
211 Content-Transfer-Encoding: 8bit
212
213 <html>
214 <head>
215 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
216 <meta name="Generator" content="Microsoft Exchange Server">
217 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
218 </head>
219 <body>
220 <div>
221 <div>Need to go! Need ... to ... go!</div>
222 </body>
223 </html>
224
225 ------=_nmh-multipart--
226 EOF
227
228 cat >"$MH_TEST_DIR"/Mail/inbox/12 <<EOF
229 MIME-Version: 1.0
230 From: sender@example.com
231 To: bonquiqui@example.com
232 Subject: rue
233 Date: Sat, 26 Jan 2013 17:37:53 -0500
234 Content-Type: text/html; charset="Windows-1252"
235 Content-Transfer-Encoding: quoted-printable
236
237 <html>
238 <head>
239 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
240 252">
241 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
242 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
243 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
244 </head>
245 <body>
246 <div>
247 <div>Need to go! Need ... to ... go!</div>
248 </body>
249 </html>
250 EOF
251
252 if [ $can_reformat_texthtml -eq 1 ]; then
253 printf '%s\n' "mhfixmsg: 12, insert text/plain part
254 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
255 >"$expected.err"
256
257 #### lynx inserts multiple blank lines, so squeeze them.
258 run_prog mhfixmsg last -outfile - -verbose 2>"$actual.err" | \
259 squeeze_lines >"$actual"
260 check "$expected" "$actual" 'ignore space'
261 check "$expected.err" "$actual.err"
262 else
263 rm -f "$expected"
264 fi
265
266
267 # check implicit -file with absolute pathname
268 run_test "mhfixmsg `mhpath last` -outfile /dev/null" ''
269
270
271 # check handling of boundary string that appears in message body
272 #
273 prepare_space >"$expected" <<EOF
274 MIME-Version: 1.0
275 From: sender@example.com
276 To: bonquiqui@example.com
277 Subject: rue
278 Date: Sat, 26 Jan 2013 17:37:53 -0500
279 Content-Type: multipart/alternative; boundary="----=_nmh-multipart-3"
280
281 ------=_nmh-multipart-3
282 Content-Type: text/plain; charset="Windows-1252"
283 Content-Transfer-Encoding: 8bit
284
285 ------=_nmh-multipart
286 ------=_nmh-multipart-1
287 ------=_nmh-multipart-2
288
289 ------=_nmh-multipart-3
290 Content-Type: text/html; charset="Windows-1252"
291 Content-Transfer-Encoding: 8bit
292
293 <html>
294 <head>
295 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
296 <meta name="Generator" content="Microsoft Exchange Server">
297 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
298 </head>
299 <body>
300 ------=_nmh-multipart<br>
301 ------=_nmh-multipart-1<br>
302 ------=_nmh-multipart-2<br>
303 </body>
304 </html>
305
306 ------=_nmh-multipart-3--
307 EOF
308
309 cat >"$MH_TEST_DIR"/Mail/inbox/12 <<EOF
310 MIME-Version: 1.0
311 From: sender@example.com
312 To: bonquiqui@example.com
313 Subject: rue
314 Date: Sat, 26 Jan 2013 17:37:53 -0500
315 Content-Type: text/html; charset="Windows-1252"
316 Content-Transfer-Encoding: quoted-printable
317
318 <html>
319 <head>
320 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
321 252">
322 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
323 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
324 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
325 </head>
326 <body>
327 ------=3D_nmh-multipart<br>
328 ------=3D_nmh-multipart-1<br>
329 ------=3D_nmh-multipart-2<br>
330 </body>
331 </html>
332 EOF
333
334 if [ $can_reformat_texthtml -eq 1 ]; then
335 printf '%s\n' "mhfixmsg: 12, insert text/plain part
336 mhfixmsg: 12 part 1, decode text/html; charset=\"Windows-1252\"" \
337 >"$expected.err"
338
339 #### lynx inserts multiple blank lines, so squeeze them.
340 run_prog mhfixmsg last -outfile - -verbose 2>"$actual.err" | \
341 squeeze_lines >"$actual"
342 check "$expected" "$actual" 'ignore space'
343 check "$expected.err" "$actual.err"
344 else
345 rm -f "$expected"
346 fi
347
348
349 # check -nodecode
350 prepare_space >"$expected" <<EOF
351 MIME-Version: 1.0
352 From: sender@example.com
353 To: bonquiqui@example.com
354 Subject: rue
355 Date: Sat, 26 Jan 2013 17:37:53 -0500
356 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
357
358 ------=_nmh-multipart
359 Content-Type: text/plain; charset="Windows-1252"
360 Content-Transfer-Encoding: 8bit
361
362 Need to go! Need ... to ... go!
363
364 ------=_nmh-multipart
365 Content-Type: text/html; charset="Windows-1252"
366 Content-Transfer-Encoding: quoted-printable
367
368 <html>
369 <head>
370 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-=
371 1252">
372 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
373 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pa=
374 dding-left: 4pt; border-left: #800000 2px solid; } --></style>
375 </head>
376 <body>
377 <div>
378 <div>Need to go! Need ... to ... go!</div>
379 </body>
380 </html>
381
382 ------=_nmh-multipart--
383 EOF
384
385 cat >"$MH_TEST_DIR"/Mail/inbox/12 <<EOF
386 MIME-Version: 1.0
387 From: sender@example.com
388 To: bonquiqui@example.com
389 Subject: rue
390 Date: Sat, 26 Jan 2013 17:37:53 -0500
391 Content-Type: text/html; charset="Windows-1252"
392 Content-Transfer-Encoding: quoted-printable
393
394 <html>
395 <head>
396 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
397 252">
398 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
399 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
400 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
401 </head>
402 <body>
403 <div>
404 <div>Need to go! Need ... to ... go!</div>
405 </body>
406 </html>
407 EOF
408
409 if [ $can_reformat_texthtml -eq 1 ]; then
410 printf '%s\n' 'mhfixmsg: 12, insert text/plain part' >"$expected.err"
411
412 #### lynx inserts multiple blank lines, so squeeze them.
413 run_prog mhfixmsg last -nodecode -outfile - -verbose 2>"$actual.err" | \
414 squeeze_lines >"$actual"
415 check "$expected" "$actual" 'ignore space'
416 check "$expected.err" "$actual.err"
417 else
418 rm -f "$expected"
419 fi
420
421
422 # check -decodetext (enabled by default)
423 cat >"$expected" <<EOF
424 To: recipient@example.com
425 From: sender@example.com
426 Subject: mhfixmsg decode test 1
427 MIME-Version: 1.0
428 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
429
430 ------- =_aaaaaaaaaa0
431 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
432 Content-Disposition: attachment; filename="test4.txt"
433 Content-Transfer-Encoding: 8bit
434
435 This is a text/plain part.
436
437 ------- =_aaaaaaaaaa0--
438 EOF
439
440 cat >`mhpath new` <<EOF
441 To: recipient@example.com
442 From: sender@example.com
443 Subject: mhfixmsg decode test 1
444 MIME-Version: 1.0
445 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
446
447 ------- =_aaaaaaaaaa0
448 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
449 Content-Disposition: attachment; filename="test4.txt"
450 Content-Transfer-Encoding: base64
451
452 VGhpcyBpcyBhIHRleHQvcGxhaW4gcGFydC4K
453
454 ------- =_aaaaaaaaaa0--
455 EOF
456
457 run_prog mhfixmsg last -outfile "$actual"
458 check "$expected" "$actual"
459
460
461 # check -decodetext with more complicated content structure
462 cat >$expected <<EOF
463 To: recipient@example.com
464 From: sender@example.com
465 Subject: mhfixmsg decode test 2
466 MIME-Version: 1.0
467 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
468
469 This is additional content before the first subpart of the multipart.
470
471 ------- =_aaaaaaaaaa0
472 Content-Type: multipart/related;
473 type="text/plain"; boundary="subpart__1.1"
474
475 --subpart__1.1
476 Content-Type: text/plain; charset="iso-8859-1"
477 Content-Disposition: attachment; filename="test1.txt"
478
479 This is the first text/plain part, in a subpart.
480
481 --subpart__1.1--
482
483 This is additional content after the last subpart of the multipart.
484
485 ------- =_aaaaaaaaaa0
486 Content-Type: text/plain; charset="iso-8859-1"
487 Content-Disposition: attachment; filename="test2.txt"
488 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
489 Content-Transfer-Encoding: 8bit
490
491 This is the second text/plain part.
492
493 ------- =_aaaaaaaaaa0
494 Content-Type: text/plain; charset="iso-8859-1"
495 Content-Disposition: attachment; filename="test3.txt"
496
497 This is the third text/plain part.
498
499 ------- =_aaaaaaaaaa0
500 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
501 Content-Disposition: attachment; filename="test4.txt"
502 Content-Transfer-Encoding: 8bit
503
504 This is the fourth text/plain part.
505
506 ------- =_aaaaaaaaaa0--
507
508 This is additional content after the last subpart of the multipart.
509 EOF
510
511 cat >`mhpath new` <<EOF
512 To: recipient@example.com
513 From: sender@example.com
514 Subject: mhfixmsg decode test 2
515 MIME-Version: 1.0
516 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
517
518 This is additional content before the first subpart of the multipart.
519
520 ------- =_aaaaaaaaaa0
521 Content-Type: multipart/related;
522 type="text/plain"; boundary="subpart__1.1"
523
524 --subpart__1.1
525 Content-Type: text/plain; charset="iso-8859-1"
526 Content-Disposition: attachment; filename="test1.txt"
527
528 This is the first text/plain part, in a subpart.
529
530 --subpart__1.1--
531
532 This is additional content after the last subpart of the multipart.
533
534 ------- =_aaaaaaaaaa0
535 Content-Type: text/plain; charset="iso-8859-1"
536 Content-Disposition: attachment; filename="test2.txt"
537 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
538 Content-Transfer-Encoding: quoted-printable
539
540 This is the second text/plain part.
541
542 ------- =_aaaaaaaaaa0
543 Content-Type: text/plain; charset="iso-8859-1"
544 Content-Disposition: attachment; filename="test3.txt"
545
546 This is the third text/plain part.
547
548 ------- =_aaaaaaaaaa0
549 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
550 Content-Disposition: attachment; filename="test4.txt"
551 Content-Transfer-Encoding: base64
552
553 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
554
555 ------- =_aaaaaaaaaa0--
556
557 This is additional content after the last subpart of the multipart.
558 EOF
559 run_prog mhfixmsg last -outfile "$actual"
560 check "$expected" "$actual"
561
562
563 # check attempted -decodetext of binary text
564 #### Generated the encoded text below with:
565 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
566 cat >`mhpath new` <<EOF
567 To: recipient@example.com
568 From: sender@example.com
569 Subject: mhfixmsg attempted binary decode test
570 MIME-Version: 1.0
571 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
572
573 ------- =_aaaaaaaaaa0
574 Content-Type: text/plain; charset="iso-8859-1"; name="nul+square.txt"
575 Content-Transfer-Encoding: base64
576
577 AL2yPbwK
578
579 ------- =_aaaaaaaaaa0--
580 EOF
581
582 cp -p `mhpath last` "$expected"
583 run_prog mhfixmsg last
584 check `mhpath last` "$expected" 'keep first'
585
586
587 # check for successful decode of a different part with attempted -decodetext
588 # of binary text
589 #### Generated the encoded text below with:
590 #### $ printf '\x0\xbd\xb2=\xbc\n' | base64
591 cat >$expected <<EOF
592 To: recipient@example.com
593 From: sender@example.com
594 Subject: mhfixmsg successful decode of text/plain with failed binary decode
595 MIME-Version: 1.0
596 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
597
598 ------- =_aaaaaaaaaa0
599 Content-Type: text/plain; charset="iso-8859-1"
600 Content-Transfer-Encoding: 8bit
601
602 This is a text plain part
603
604 ------- =_aaaaaaaaaa0
605 Content-Type: text/html; charset="ascii"
606 Content-Transfer-Encoding: base64
607 Content-Disposition: inline
608
609 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
610 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
611 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
612 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
613 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
614 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
615 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
616 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
617 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
618 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
619 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
620 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
621 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
622 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
623 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
624 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
625 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
626 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
627 ICA8L2JvZHk+PC9odG1sPg==
628
629 ------- =_aaaaaaaaaa0--
630 EOF
631
632 cat >`mhpath new` <<EOF
633 To: recipient@example.com
634 From: sender@example.com
635 Subject: mhfixmsg successful decode of text/plain with failed binary decode
636 MIME-Version: 1.0
637 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
638
639 ------- =_aaaaaaaaaa0
640 Content-Type: text/plain; charset="iso-8859-1"
641 Content-Transfer-Encoding: base64
642
643 VGhpcyBpcyBhIHRleHQgcGxhaW4gcGFydAo=
644
645 ------- =_aaaaaaaaaa0
646 Content-Type: text/html; charset="ascii"
647 Content-Transfer-Encoding: base64
648 Content-Disposition: inline
649
650 PGh0bWw+PGhlYWQ+PHRpdGxlPmxvbmcgbGluZTwvdGl0bGU+PC9oZWFkPjxib2R5PlRoaXMgbGlu
651 ZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQg
652 c2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hh
653 cmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBU
654 aGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhp
655 cyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4g
656 OTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNv
657 ZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgs
658 IHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRl
659 ciB0aGFuIDk5OCBjaGFyYWN0ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3Qg
660 YmUgZGVjb2RlZC4gIFRoaXMgbGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4g
661 bGVuZ3RoLCBzbyB0aGlzIHBhcnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlz
662 IGdyZWF0ZXIgdGhhbiA5OTggY2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91
663 bGQgbm90IGJlIGRlY29kZWQuICBUaGlzIGxpbmUgaXMgZ3JlYXRlciB0aGFuIDk5OCBjaGFyYWN0
664 ZXJzIGluIGxlbmd0aCwgc28gdGhpcyBwYXJ0IHNob3VsZCBub3QgYmUgZGVjb2RlZC4gIFRoaXMg
665 bGluZSBpcyBncmVhdGVyIHRoYW4gOTk4IGNoYXJhY3RlcnMgaW4gbGVuZ3RoLCBzbyB0aGlzIHBh
666 cnQgc2hvdWxkIG5vdCBiZSBkZWNvZGVkLiAgVGhpcyBsaW5lIGlzIGdyZWF0ZXIgdGhhbiA5OTgg
667 Y2hhcmFjdGVycyBpbiBsZW5ndGgsIHNvIHRoaXMgcGFydCBzaG91bGQgbm90IGJlIGRlY29kZWQu
668 ICA8L2JvZHk+PC9odG1sPg==
669
670 ------- =_aaaaaaaaaa0--
671 EOF
672
673 run_prog mhfixmsg -noreformat last
674 check `mhpath last` "$expected"
675
676
677 # check -decodetext of binary text
678 printf "%s\x0d\xbd\xb2=\xbc%s" "To: recipient@example.com
679 From: sender@example.com
680 Subject: mhfixmsg binary decode test
681 MIME-Version: 1.0
682 Content-Type: multipart/mixed; boundary=\"----- =_aaaaaaaaaa0\"
683
684 ------- =_aaaaaaaaaa0
685 Content-Type: text/plain; charset=\"iso-8859-1\"; name=\"nul+square.txt\"
686 Content-Transfer-Encoding: binary
687
688 " "
689
690 ------- =_aaaaaaaaaa0--
691 " >"$expected"
692 ## output_content() in mhoutsbr.c can't handle binary content.
693 ## mhfixmsg last -decodetext binary -outfile "$actual"
694 ## check "$expected" "$actual"
695 rm -f "$expected"
696 rmm last
697
698
699 # check that -reformat succeeds when decode of binary text fails
700 prepare_space >"$expected" <<'EOF'
701 MIME-Version: 1.0
702 Date: Thu, 11 Apr 2013 02:47:08 -0700
703 To: <me@example.com>
704 From: <sender@example.com>
705 Subject: body requires binary encoding
706 Content-Type: multipart/alternative; boundary="----=_nmh-multipart"
707
708 ------=_nmh-multipart
709 Content-Type: text/plain; charset="ISO-8859-1"
710 Content-Transfer-Encoding: 8bit
711
712 Mile $0.00
713 Time $78.71
714 State Tax $5.90
715 Vehicle License Fee $1.84
716 State Txn Tax $6.00
717
718 ------=_nmh-multipart
719 Content-Type: text/html; charset="ISO-8859-1"
720 Content-Transfer-Encoding: quoted-printable
721
722 <body>
723 EOF
724
725 cat >`mhpath new` <<'EOF'
726 MIME-Version: 1.0
727 Content-Type: text/html; charset="ISO-8859-1"
728 Content-Transfer-Encoding: quoted-printable
729 Date: Thu, 11 Apr 2013 02:47:08 -0700
730 To: <me@example.com>
731 From: <sender@example.com>
732 Subject: body requires binary encoding
733
734 <body>
735 <table width=3D"325" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
736 <tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
737 =3D"2"><strong>Mile</strong></font></td><td height=3D"3">&nbsp;</td><td ali=
738 gn=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" =
739 size=3D"2">$0.00</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sa=
740 ns-serif" color=3D"#333333" size=3D"2"><strong>Time</strong></font></td><td=
741 height=3D"3">&nbsp;</td><td align=3D"right"><font face=3D"Arial, Helvetica=
742 , sans-serif" color=3D"#333333" size=3D"2">$78.71</font></td></tr><tr><td><=
743 font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=3D"2"><st=
744 rong>State Tax</strong></font></td><td height=3D"3">&nbsp;</td><td align=3D=
745 "right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
746 =3D"2">$5.90</font></td></tr><tr><td><font face=3D"Arial, Helvetica, sans-s=
747 erif" color=3D"#333333" size=3D"2"><strong>Vehicle License Fee</strong></fo=
748 nt></td><td height=3D"3">&nbsp;</td><td align=3D"right"><font face=3D"Arial=
749 , Helvetica, sans-serif" color=3D"#333333" size=3D"2">$1.84</font></td></tr=
750 ><tr><td><font face=3D"Arial, Helvetica, sans-serif" color=3D"#333333" size=
751 =3D"2"><strong>State Txn Tax</strong></font></td><td height=3D"3">&nbsp;</t=
752 d><td align=3D"right"><font face=3D"Arial, Helvetica, sans-serif" color=3D"=
753 #333333" size=3D"2">$6.00</font></td></tr>
754
755 </body>
756 </html>
757 EOF
758
759 if [ $can_reformat_texthtml -eq 1 ]; then
760 #### lynx inserts multiple blank lines, so squeeze them.
761 #### Truncate to avoid comparing the html portion because it can
762 #### get reformatted.
763 run_prog mhfixmsg last -outfile - | squeeze_lines | head -22 >"$actual"
764 check "$expected" "$actual" 'ignore space'
765 else
766 cp -p "$MH_TEST_DIR/Mail/inbox/15" "$MH_TEST_DIR/Mail/inbox/15.backup"
767 rm -f "$expected"
768 fi
769
770
771 # check -textcharset
772 # Also checks preservation of attributes after one (charset) that is
773 # modified.
774 cat >"$expected" <<EOF
775 To: recipient@example.com
776 From: sender@example.com
777 Subject: mhfixmsg textcharset test
778 MIME-Version: 1.0
779 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
780
781 ------- =_aaaaaaaaaa0
782 Content-Type: text/plain; charset="utf-8"; name="square.txt"
783 Content-Disposition: attachment; filename="square.txt"
784 Content-Transfer-Encoding: 8bit
785
786 ½²=¼
787
788 ------- =_aaaaaaaaaa0--
789 EOF
790
791 #### Generated the encoded text below with:
792 #### $ printf '\xbd\xb2=\xbc\n' | base64
793 cat >`mhpath new` <<EOF
794 To: recipient@example.com
795 From: sender@example.com
796 Subject: mhfixmsg textcharset test
797 MIME-Version: 1.0
798 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
799
800 ------- =_aaaaaaaaaa0
801 Content-Type: text/plain; charset="iso-8859-1"; name="square.txt"
802 Content-Disposition: attachment; filename="square.txt"
803 Content-Transfer-Encoding: base64
804
805 vbI9vAo=
806
807 ------- =_aaaaaaaaaa0--
808 EOF
809
810 if test "$ICONV_ENABLED" -eq 1; then
811 run_prog mhfixmsg last -textcharset utf-8 -outfile "$actual" 2>&1
812 check "$expected" "$actual"
813 else
814 echo "$0: skipping -textcharset check because nmh was built without iconv"
815 rm -f "$expected"
816 fi
817
818
819 # check -nofixboundary
820 cat >"$expected" <<EOF
821 EOF
822
823 cat >`mhpath new` <<EOF
824 Date: Fri, 13 May 2011 08:21:12 -0500
825 Content-Type: multipart/alternative;
826 boundary="----=_NextPart_000_1781A17_01CC1147.81E9467A"
827 Content-Transfer-Encoding: 8bit
828 MIME-Version: 1.0
829 From: <sender@example.com>
830 To: <recipient@example.com>
831 Subject: mhfixmsg bad boundary test
832
833 This is a multi-part message in MIME format.
834
835 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
836 Content-Type: text/plain
837
838 The boundaries of this part don't match the header boundary.
839
840 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
841 EOF
842
843 cp -p `mhpath last` `mhpath new`
844
845 run_test 'mhfixmsg last -nofixboundary' ''
846 check "$MH_TEST_DIR"/Mail/inbox/17 "$MH_TEST_DIR"/Mail/inbox/18 'keep first'
847
848
849 # check that message is not output when fed through stdin
850 run_prog mhfixmsg -file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
851 check "$expected" "$actual"
852 if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
853 "$actual.err" >/dev/null; then
854 rm -f "$actual.err"
855 else
856 echo "$0: test failed, output is in $actual.err."
857 failed=`expr ${failed:-0} + 1`
858 fi
859
860
861 # check fixup of erroneous boundary in multipart (-fixboundary,
862 # enabled by default)
863 # check -verbose
864 cat >"$expected" <<EOF
865 Date: Fri, 13 May 2011 08:21:12 -0500
866 Content-Type: multipart/alternative;
867 boundary="----=_NextPart_000_1781A1A_01CC1147.81EBA8D4"
868 Content-Transfer-Encoding: 8bit
869 MIME-Version: 1.0
870 From: <sender@example.com>
871 To: <recipient@example.com>
872 Subject: mhfixmsg bad boundary test
873
874 This is a multi-part message in MIME format.
875
876 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4
877 Content-Type: text/plain
878
879 The boundaries of this part don't match the header boundary.
880
881 ------=_NextPart_000_1781A1A_01CC1147.81EBA8D4--
882 EOF
883
884 run_test 'mhfixmsg last -outfile '"$actual"' -verbose' \
885 "mhfixmsg: 17, fix multipart boundary"
886 check "$expected" "$actual"
887
888
889 # check that text/plain part is not added to text/html in multipart/related
890 # when it shouldn't be
891 cat >`mhpath new` <<EOF
892 MIME-Version: 1.0
893 Date: Tue, 26 Feb 2013 18:07:20 -0600
894 Subject: multipart/related, not /alternative
895 Content-Type: multipart/related;
896 type="text/html"; boundary="----=_Part_90310_101292502.1"
897
898 ------=_Part_90310_101292502.1
899 Content-Type: text/html; charset="us-ascii"
900 Content-Transfer-Encoding: 7bit
901
902 <html><head>
903 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
904 <title>HTML Content</title>
905 </head>
906 <body>
907 This is the real content.
908 </body>
909 </html>
910
911 ------=_Part_90310_101292502.1
912 Content-Type: text/plain; charset="us-ascii"
913 Content-Transfer-Encoding: 7bit
914
915 Your email client does not support HTML messages
916
917 ------=_Part_90310_101292502.1--
918 EOF
919
920 cp -p `mhpath last` "$expected"
921
922 if [ $can_reformat_texthtml -eq 1 ]; then
923 #### lynx inserts multiple blank lines, so squeeze them.
924 run_prog mhfixmsg last -outfile - | squeeze_lines >"$actual"
925 check "$expected" "$actual" 'ignore space'
926 else
927 rm -f "$expected"
928 fi
929
930
931 # check that text/plain part is added to text/html in multipart/related
932 # when it should be
933 cat >"$expected" <<EOF
934 MIME-Version: 1.0
935 Date: Tue, 26 Feb 2013 18:07:20 -0600
936 Subject: multipart/related, not /alternative
937 Content-Type: multipart/alternative; boundary="----=_Part_90310_101292502.1"
938
939 ------=_Part_90310_101292502.1
940 Content-Type: text/plain; charset="us-ascii"
941 Content-Transfer-Encoding: 7bit
942
943 This is the real content.
944
945 ------=_Part_90310_101292502.1
946 Content-Type: text/html; charset="us-ascii"
947 Content-Transfer-Encoding: 7bit
948
949 <html><head>
950 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
951 <title>HTML Content</title>
952 </head>
953 <body>
954 This is the real content.
955 </body>
956 </html>
957
958 ------=_Part_90310_101292502.1--
959 EOF
960
961 cat >`mhpath new` <<EOF
962 MIME-Version: 1.0
963 Date: Tue, 26 Feb 2013 18:07:20 -0600
964 Subject: multipart/related, not /alternative
965 Content-Type: multipart/related;
966 type="text/html"; boundary="----=_Part_90310_101292502.1"
967
968 ------=_Part_90310_101292502.1
969 Content-Type: text/html; charset="us-ascii"
970 Content-Transfer-Encoding: 7bit
971
972 <html><head>
973 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
974 <title>HTML Content</title>
975 </head>
976 <body>
977 This is the real content.
978 </body>
979 </html>
980
981 ------=_Part_90310_101292502.1--
982 EOF
983
984 if [ $can_reformat_texthtml -eq 1 ]; then
985 #### lynx inserts multiple blank lines, so squeeze them.
986 run_prog mhfixmsg last -outfile - | squeeze_lines >"$actual"
987 check "$expected" "$actual" 'ignore space'
988 else
989 rm -f "$expected"
990 fi
991
992
993 # check handling of rfc822 message type
994 cat >"$expected" <<EOF
995 From: Test <test@example.com>
996 To: Some User <user@example.com>
997 Date: Fri, 29 Sep 2006 00:00:00
998 Message-Id: @test.nmh
999 Subject: message with message/rfc822 attachment
1000 MIME-Version: 1.0
1001 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1002
1003 and some garbage before the attachment
1004
1005 ------- =_aaaaaaaaaa0
1006 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1007 Content-Description: 1552
1008 Content-Disposition: attachment; filename="1552"
1009
1010 From: Test <test@example.com>
1011 To: <another_user@example.com>
1012 Date: Thu, 28 Sep 2006 00:00:00
1013 Message-Id: @test.nmh
1014 Subject: message/rfc822 attachment
1015
1016 This is an RFC-822 message.
1017
1018 ------- =_aaaaaaaaaa0--
1019
1020 and some garbage at the end
1021 EOF
1022
1023 cat >`mhpath new` <<EOF
1024 From: Test <test@example.com>
1025 To: Some User <user@example.com>
1026 Date: Fri, 29 Sep 2006 00:00:00
1027 Message-Id: @test.nmh
1028 Subject: message with message/rfc822 attachment
1029 MIME-Version: 1.0
1030 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaa0"
1031
1032 and some garbage before the attachment
1033
1034 ------- =_aaaaaaaaaa0
1035 Content-Type: message/rfc822; name="1552"; charset="us-ascii"
1036 Content-Description: 1552
1037 Content-Disposition: attachment; filename="1552"
1038
1039 From: Test <test@example.com>
1040 To: <another_user@example.com>
1041 Date: Thu, 28 Sep 2006 00:00:00
1042 Message-Id: @test.nmh
1043 Subject: message/rfc822 attachment
1044
1045 This is an RFC-822 message.
1046
1047 ------- =_aaaaaaaaaa0--
1048
1049 and some garbage at the end
1050 EOF
1051
1052 run_test 'mhfixmsg last -outfile '"$actual" ''
1053 check "$expected" "$actual"
1054
1055
1056 # check stripping of CRs from ASCII text context
1057 cat >"$expected" <<EOF
1058 MIME-Version: 1.0
1059 From: sender@example.com
1060 To: recipient@example.com
1061 Subject: message with CR's
1062 Date: Mon, 29 Apr 2013 11:51:45 -0400
1063
1064 There are two CR-LF pairs at the end of this sentence.
1065
1066 EOF
1067
1068 cat >`mhpath new` <<'EOF'
1069 MIME-Version: 1.0
1070 From: sender@example.com
1071 To: recipient@example.com
1072 Subject: message with CR's
1073 Date: Mon, 29 Apr 2013 11:51:45 -0400
1074
1075 There are two CR-LF pairs at the end of this sentence.
1076
1077 EOF
1078
1079 run_prog mhfixmsg last -outfile "$actual"
1080 check "$expected" "$actual"
1081
1082
1083 # check -replacetextplain
1084 prepare_space >"$expected" <<EOF
1085 To: recipient@example.com
1086 From: sender@example.com
1087 Subject: mhfixmsg replacement of bad text/plain part test
1088 MIME-Version: 1.0
1089 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1090
1091 ------=_Part_876302
1092 Content-Type: text/plain; charset="UTF-8"
1093 Content-Transfer-Encoding: 8bit
1094
1095 Yes, the text/plain part really was empty.
1096
1097 ------=_Part_876302
1098 Content-Type: text/html; charset="UTF-8"
1099 Content-Transfer-Encoding: 8bit
1100 Content-Disposition: inline
1101
1102 <html><head>
1103 <title>eticket</title>
1104 </head>
1105 <body>
1106 Yes, the text/plain part really was empty.
1107 </body>
1108 </html>
1109
1110 ------=_Part_876302--
1111 EOF
1112
1113 cat >`mhpath new` <<'EOF'
1114 To: recipient@example.com
1115 From: sender@example.com
1116 Subject: mhfixmsg replacement of bad text/plain part test
1117 MIME-Version: 1.0
1118 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1119
1120 ------=_Part_876302
1121 Content-Type: text/plain; charset="iso-8859-15"
1122 Content-Transfer-Encoding: 7bit
1123 Content-Disposition: inline
1124
1125
1126
1127 ------=_Part_876302
1128 Content-Type: text/html; charset="UTF-8"
1129 Content-Transfer-Encoding: 8bit
1130 Content-Disposition: inline
1131
1132 <html><head>
1133 <title>eticket</title>
1134 </head>
1135 <body>
1136 Yes, the text/plain part really was empty.
1137 </body>
1138 </html>
1139
1140 ------=_Part_876302--
1141 EOF
1142
1143 if [ $can_reformat_texthtml -eq 1 ]; then
1144 #### lynx inserts multiple blank lines, so squeeze them.
1145 run_prog mhfixmsg last -replacetextplain -outfile - | \
1146 squeeze_lines > "$actual"
1147 check "$expected" "$actual" 'ignore space'
1148 else
1149 rm -f "$expected"
1150 fi
1151
1152
1153 # check -noreplacetextplain
1154 cat >"$expected" <<EOF
1155 To: recipient@example.com
1156 From: sender@example.com
1157 Subject: mhfixmsg replacement of bad text/plain part test
1158 MIME-Version: 1.0
1159 Content-Type: multipart/alternative; boundary="----=_Part_876302"
1160
1161 ------=_Part_876302
1162 Content-Type: text/plain; charset="iso-8859-15"
1163 Content-Transfer-Encoding: 7bit
1164 Content-Disposition: inline
1165
1166
1167
1168 ------=_Part_876302
1169 Content-Type: text/html; charset="UTF-8"
1170 Content-Transfer-Encoding: 8bit
1171 Content-Disposition: inline
1172
1173 <html><head>
1174 <title>eticket</title>
1175 </head>
1176 <body>
1177 Yes, the text/plain part really was empty.
1178 </body>
1179 </html>
1180
1181 ------=_Part_876302--
1182 EOF
1183
1184 run_prog mhfixmsg last -replacetextplain -noreplacetextplain -outfile "$actual"
1185 check "$expected" "$actual"
1186
1187
1188 # check removal of extraneous trailing semicolon from header parameter list
1189 cat >"$expected" <<EOF
1190 To: recipient@example.com
1191 Subject: test
1192 From: sender@example.com
1193 MIME-Version: 1.0
1194 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1195
1196 ------- =_aaaaaaaaaa0
1197 Content-Type: text/plain; charset="us-ascii"
1198
1199 test
1200
1201 ------- =_aaaaaaaaaa0
1202 Content-Type: text/plain; charset="us-ascii";
1203 name="DATE"
1204 Content-Description: check folded headers, with and without trailing semicolon
1205 Content-Disposition: attachment;
1206 filename="DATE"
1207
1208 14 April 2014
1209
1210 ------- =_aaaaaaaaaa0--
1211 EOF
1212
1213 cat >`mhpath new` <<EOF
1214 To: recipient@example.com
1215 Subject: test
1216 From: sender@example.com
1217 MIME-Version: 1.0
1218 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1219
1220 ------- =_aaaaaaaaaa0
1221 Content-Type: text/plain; charset="us-ascii";
1222
1223 test
1224
1225 ------- =_aaaaaaaaaa0
1226 Content-Type: text/plain; charset="us-ascii";
1227 name="DATE"
1228 Content-Description: check folded headers, with and without trailing semicolon
1229 Content-Disposition: attachment;
1230 filename="DATE";
1231
1232 14 April 2014
1233
1234 ------- =_aaaaaaaaaa0--
1235 EOF
1236 run_test 'mhfixmsg last -outfile '"$actual" ''
1237 check "$expected" "$actual"
1238
1239
1240 # check rmmproc
1241 cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
1242 mv "$1" "$1.backup"
1243 EOF
1244 chmod a+x "${MH_TEST_DIR}/Mail/rmmproc"
1245 echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
1246 cp "${MH_TEST_DIR}/Mail/inbox/15" "${MH_TEST_DIR}/Mail/inbox/15.original"
1247
1248 run_test 'mhfixmsg 15' ''
1249 check "${MH_TEST_DIR}/Mail/inbox/15.backup" \
1250 "${MH_TEST_DIR}/Mail/inbox/15.original"
1251
1252
1253 # check -normmproc
1254 cp "${MH_TEST_DIR}/Mail/inbox/19" "${MH_TEST_DIR}/Mail/inbox/20"
1255
1256 run_test 'mhfixmsg 19 -normmproc'
1257 check "${MH_TEST_DIR}/Mail/inbox/20" \
1258 "${MH_TEST_DIR}/Mail/inbox/,19" 'keep first'
1259
1260
1261 # check -rmmproc
1262 run_test 'mhfixmsg 20 -rmmproc true'
1263 if test -f '${MH_TEST_DIR}/Mail/inbox/20.backup'; then
1264 echo check of mhfixmsg -rmmproc FAILED, should not have created backup file
1265 failed=`expr ${failed:-0} + 1`
1266 fi
1267
1268
1269 # check -fixtype
1270 cat >"$expected" <<EOF
1271 To: recipient@example.com
1272 From: sender@example.com
1273 Subject: mhfixmsg with incorrect Content-Type
1274 MIME-Version: 1.0
1275 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1276
1277 ------- =_aaaaaaaaaa0
1278 Content-Type: text/plain; name="plaintext.txt"
1279
1280 this is plain text
1281
1282 ------- =_aaaaaaaaaa0--
1283 EOF
1284
1285 cat >`mhpath new` <<EOF
1286 To: recipient@example.com
1287 From: sender@example.com
1288 Subject: mhfixmsg with incorrect Content-Type
1289 MIME-Version: 1.0
1290 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1291
1292 ------- =_aaaaaaaaaa0
1293 Content-Type: application/octet-stream; name="plaintext.txt"
1294
1295 this is plain text
1296
1297 ------- =_aaaaaaaaaa0--
1298 EOF
1299
1300 mhfixmsg -fixtype application/octet-stream last
1301 check "$expected" `mhpath last`
1302
1303
1304 # check default -decodetypes
1305 cat >$expected <<EOF
1306 To: recipient@example.com
1307 From: sender@example.com
1308 Subject: mhfixmsg decode test 3
1309 MIME-Version: 1.0
1310 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1311
1312 ------- =_aaaaaaaaaa0
1313 Content-Type: text/plain; charset="iso-8859-1"
1314 Content-Disposition: attachment; filename="test1.txt"
1315 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1316 Content-Transfer-Encoding: 8bit
1317
1318 This is the text/plain part.
1319
1320 ------- =_aaaaaaaaaa0
1321 Content-Type: text/plain; charset="iso-8859-1"; name="test2.txt"
1322 Content-Disposition: attachment; filename="test2.txt"
1323 Content-Transfer-Encoding: 8bit
1324
1325 <html>
1326 <head>
1327 This is the text/html part.
1328 </head>
1329 </body>
1330 </html>
1331
1332 ------- =_aaaaaaaaaa0--
1333 EOF
1334
1335 cat >`mhpath new` <<EOF
1336 To: recipient@example.com
1337 From: sender@example.com
1338 Subject: mhfixmsg decode test 3
1339 MIME-Version: 1.0
1340 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1341
1342 ------- =_aaaaaaaaaa0
1343 Content-Type: text/plain; charset="iso-8859-1"
1344 Content-Disposition: attachment; filename="test1.txt"
1345 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1346 Content-Transfer-Encoding: quoted-printable
1347
1348 This is the text/plain part.
1349
1350 ------- =_aaaaaaaaaa0
1351 Content-Type: text/plain; charset="iso-8859-1"; name="test2.txt"
1352 Content-Disposition: attachment; filename="test2.txt"
1353 Content-Transfer-Encoding: base64
1354
1355 PGh0bWw+CjxoZWFkPgogICAgVGhpcyBpcyB0aGUgdGV4dC9odG1sIHBhcnQuCjwvaGVhZD4KPC9i
1356 b2R5Pgo8L2h0bWw+Cg==
1357
1358 ------- =_aaaaaaaaaa0--
1359 EOF
1360 run_prog mhfixmsg last -outfile "$actual"
1361 check "$expected" "$actual"
1362
1363
1364 # check -decodetypes text/plain
1365 cat >$expected <<EOF
1366 To: recipient@example.com
1367 From: sender@example.com
1368 Subject: mhfixmsg decode test 4
1369 MIME-Version: 1.0
1370 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1371
1372 ------- =_aaaaaaaaaa0
1373 Content-Type: text/plain; charset="iso-8859-1"
1374 Content-Disposition: attachment; filename="test1.txt"
1375 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1376 Content-Transfer-Encoding: 8bit
1377
1378 This is the text/plain part.
1379
1380 ------- =_aaaaaaaaaa0
1381 Content-Type: multipart/alternative; boundary="----=_nmh-multipart2"
1382
1383 ------=_nmh-multipart2
1384 Content-Type: text/plain; charset="iso-8859-1"; name="test2.txt"
1385 Content-Transfer-Encoding: 8bit
1386
1387 This is the text/html part.
1388
1389 ------=_nmh-multipart2
1390 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1391 Content-Disposition: attachment; filename="test2.txt"
1392 Content-Transfer-Encoding: base64
1393
1394 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
1395 CjwvYm9keT4NCjwvaHRtbD4NCg==
1396
1397 ------=_nmh-multipart2--
1398
1399 ------- =_aaaaaaaaaa0--
1400 EOF
1401
1402 cat >`mhpath new` <<EOF
1403 To: recipient@example.com
1404 From: sender@example.com
1405 Subject: mhfixmsg decode test 4
1406 MIME-Version: 1.0
1407 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
1408
1409 ------- =_aaaaaaaaaa0
1410 Content-Type: text/plain; charset="iso-8859-1"
1411 Content-Disposition: attachment; filename="test1.txt"
1412 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
1413 Content-Transfer-Encoding: quoted-printable
1414
1415 This is the text/plain part.
1416
1417 ------- =_aaaaaaaaaa0
1418 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
1419 Content-Disposition: attachment; filename="test2.txt"
1420 Content-Transfer-Encoding: base64
1421
1422 PGh0bWw+CjxoZWFkPgogICAgVGhpcyBpcyB0aGUgdGV4dC9odG1sIHBhcnQuCjwvaGVhZD4KPC9i
1423 b2R5Pgo8L2h0bWw+Cg==
1424
1425 ------- =_aaaaaaaaaa0--
1426 EOF
1427 run_prog mhfixmsg last -outfile "$actual" -decodetypes text/plain
1428 check "$expected" "$actual"
1429
1430
1431 # make sure there are no tmp files left over
1432 find "$MH_TEST_DIR/Mail" \( -name 'mhfix*' -o -name ',mhfix*' \) -print \
1433 >"$actual"
1434 cat >"$expected" <<EOF
1435 EOF
1436
1437 check "$expected" "$actual"
1438
1439
1440 exit $failed