2 test_description="output of multipart message"
3 . $(dirname "$0")/test-lib.sh || exit 1
5 cat <<EOF > embedded_message_body
6 Content-Type: multipart/alternative; boundary="==-=-=="
9 Content-Type: text/html
11 <p>This is an embedded message, with a multipart/alternative part.</p>
14 Content-Type: text/plain
16 This is an embedded message, with a multipart/alternative part.
20 cat <<EOF > embedded_message
21 From: Carl Worth <cworth@cworth.org>
24 Date: Fri, 05 Jan 2001 15:42:57 +0000
25 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
26 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
30 cat embedded_message_body >> embedded_message
32 cat <<EOF > multipart_body
33 Content-Type: multipart/signed; boundary="==-=-=";
34 micalg=pgp-sha1; protocol="application/pgp-signature"
37 Content-Type: multipart/mixed; boundary="=-=-="
40 Content-Type: message/rfc822
41 Content-Disposition: inline
45 cat embedded_message >> multipart_body
46 cat <<EOF >> multipart_body
49 Content-Disposition: attachment; filename=attachment
51 This is a text attachment.
55 And this message is signed.
62 Content-Type: application/pgp-signature
64 -----BEGIN PGP SIGNATURE-----
65 Version: GnuPG v1.4.11 (GNU/Linux)
67 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
68 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
70 -----END PGP SIGNATURE-----
74 cat <<EOF > ${MAIL_DIR}/multipart
75 From: Carl Worth <cworth@cworth.org>
77 Subject: Multipart message
78 Date: Fri, 05 Jan 2001 15:43:57 +0000
79 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
80 Message-ID: <87liy5ap00.fsf@yoom.home.cworth.org>
84 cat multipart_body >> ${MAIL_DIR}/multipart
86 cat <<EOF > ${MAIL_DIR}/base64-part-with-crlf
87 From: Carl Worth <cworth@cworth.org>
89 Subject: Test message with a BASE64 encoded binary containing CRLF pair
90 Date: Fri, 05 Jan 2001 15:43:57 +0000
91 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
92 Message-ID: <base64-part-with-crlf>
94 Content-Type: multipart/mixed; boundary="==-=-=";
98 The attached BASE64-encoded part expands to a binary containing a CRLF
99 pair (that is one bye of 0x0D followed by one byte of 0x0A). This is
100 designed to ensure that notmuch is not corrupting the output of this
101 part by converting the CRLF pair to an LF only (as would be appropriate
102 for display of a text part on a Linux system, for example).
104 The part should be a 3-byte file with the following sequence of 3
110 Content-Type: application/octet-stream
111 Content-Disposition: attachment; filename=crlf.bin
112 Content-Transfer-Encoding: base64
118 cat <<EOF > content_types
119 From: Todd <todd@example.com>
121 Subject: odd content types
122 Date: Mon, 12 Jan 2014 18:12:32 +0000
123 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
124 Message-ID: <KfjfO2WJBw2hrV2p0gjT@example.com>
126 Content-Type: multipart/alternative; boundary="==-=-=="
129 Content-Type: application/unique_identifier
131 <p>This is an embedded message, with a multipart/alternative part.</p>
134 Content-Type: text/some_other_identifier
136 This is an embedded message, with a multipart/alternative part.
140 cat content_types >> ${MAIL_DIR}/odd_content_type
141 notmuch new > /dev/null
143 test_begin_subtest "--format=text --part=0, full message"
144 notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
146 \fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 excluded:0 filename:${MAIL_DIR}/multipart
148 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
149 Subject: Multipart message
150 From: Carl Worth <cworth@cworth.org>
151 To: cworth@cworth.org
152 Date: Fri, 05 Jan 2001 15:43:57 +0000
155 \fpart{ ID: 1, Content-type: multipart/signed
156 \fpart{ ID: 2, Content-type: multipart/mixed
157 \fpart{ ID: 3, Content-type: message/rfc822
159 Subject: html message
160 From: Carl Worth <cworth@cworth.org>
161 To: cworth@cworth.org
162 Date: Fri, 05 Jan 2001 15:42:57 +0000
165 \fpart{ ID: 4, Content-type: multipart/alternative
166 \fpart{ ID: 5, Content-type: text/html
167 Non-text part: text/html
169 \fpart{ ID: 6, Content-type: text/plain
170 This is an embedded message, with a multipart/alternative part.
175 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
176 This is a text attachment.
178 \fpart{ ID: 8, Content-type: text/plain
179 And this message is signed.
184 \fpart{ ID: 9, Content-type: application/pgp-signature
185 Non-text part: application/pgp-signature
191 test_expect_equal_file EXPECTED OUTPUT
193 test_begin_subtest "--format=text --part=0 --body=false, message header"
194 notmuch show --format=text --part=0 --body=false 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
196 \fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 excluded:0 filename:${MAIL_DIR}/multipart
198 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
199 Subject: Multipart message
200 From: Carl Worth <cworth@cworth.org>
201 To: cworth@cworth.org
202 Date: Fri, 05 Jan 2001 15:43:57 +0000
206 test_expect_equal_file EXPECTED OUTPUT
208 test_begin_subtest "--format=text --part=1, message body"
209 notmuch show --format=text --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
211 \fpart{ ID: 1, Content-type: multipart/signed
212 \fpart{ ID: 2, Content-type: multipart/mixed
213 \fpart{ ID: 3, Content-type: message/rfc822
215 Subject: html message
216 From: Carl Worth <cworth@cworth.org>
217 To: cworth@cworth.org
218 Date: Fri, 05 Jan 2001 15:42:57 +0000
221 \fpart{ ID: 4, Content-type: multipart/alternative
222 \fpart{ ID: 5, Content-type: text/html
223 Non-text part: text/html
225 \fpart{ ID: 6, Content-type: text/plain
226 This is an embedded message, with a multipart/alternative part.
231 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
232 This is a text attachment.
234 \fpart{ ID: 8, Content-type: text/plain
235 And this message is signed.
240 \fpart{ ID: 9, Content-type: application/pgp-signature
241 Non-text part: application/pgp-signature
245 test_expect_equal_file EXPECTED OUTPUT
247 test_begin_subtest "--format=text --part=2, multipart/mixed"
248 notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
250 \fpart{ ID: 2, Content-type: multipart/mixed
251 \fpart{ ID: 3, Content-type: message/rfc822
253 Subject: html message
254 From: Carl Worth <cworth@cworth.org>
255 To: cworth@cworth.org
256 Date: Fri, 05 Jan 2001 15:42:57 +0000
259 \fpart{ ID: 4, Content-type: multipart/alternative
260 \fpart{ ID: 5, Content-type: text/html
261 Non-text part: text/html
263 \fpart{ ID: 6, Content-type: text/plain
264 This is an embedded message, with a multipart/alternative part.
269 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
270 This is a text attachment.
272 \fpart{ ID: 8, Content-type: text/plain
273 And this message is signed.
279 test_expect_equal_file EXPECTED OUTPUT
281 test_begin_subtest "--format=text --part=3, rfc822 part"
282 notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
284 \fpart{ ID: 3, Content-type: message/rfc822
286 Subject: html message
287 From: Carl Worth <cworth@cworth.org>
288 To: cworth@cworth.org
289 Date: Fri, 05 Jan 2001 15:42:57 +0000
292 \fpart{ ID: 4, Content-type: multipart/alternative
293 \fpart{ ID: 5, Content-type: text/html
294 Non-text part: text/html
296 \fpart{ ID: 6, Content-type: text/plain
297 This is an embedded message, with a multipart/alternative part.
303 test_expect_equal_file EXPECTED OUTPUT
305 test_begin_subtest "--format=text --part=4, rfc822's multipart"
306 notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
308 \fpart{ ID: 4, Content-type: multipart/alternative
309 \fpart{ ID: 5, Content-type: text/html
310 Non-text part: text/html
312 \fpart{ ID: 6, Content-type: text/plain
313 This is an embedded message, with a multipart/alternative part.
317 test_expect_equal_file EXPECTED OUTPUT
319 test_begin_subtest "--format=text --part=5, rfc822's html part"
320 notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
322 \fpart{ ID: 5, Content-type: text/html
323 Non-text part: text/html
326 test_expect_equal_file EXPECTED OUTPUT
328 test_begin_subtest "--format=text --part=6, rfc822's text part"
329 notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
331 \fpart{ ID: 6, Content-type: text/plain
332 This is an embedded message, with a multipart/alternative part.
335 test_expect_equal_file EXPECTED OUTPUT
337 test_begin_subtest "--format=text --part=7, inline attachment"
338 notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
340 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
341 This is a text attachment.
344 test_expect_equal_file EXPECTED OUTPUT
346 test_begin_subtest "--format=text --part=8, plain text part"
347 notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
349 \fpart{ ID: 8, Content-type: text/plain
350 And this message is signed.
355 test_expect_equal_file EXPECTED OUTPUT
357 test_begin_subtest "--format=text --part=9, pgp signature (unverified)"
358 notmuch show --format=text --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
360 \fpart{ ID: 9, Content-type: application/pgp-signature
361 Non-text part: application/pgp-signature
364 test_expect_equal_file EXPECTED OUTPUT
366 test_begin_subtest "--format=text --part=8, no part, expect error"
367 test_expect_success "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
369 test_begin_subtest "--format=json --part=0, full message"
370 notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
372 {"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": ["${MAIL_DIR}/multipart"], "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
373 {"id": 1, "content-type": "multipart/signed", "content": [
374 {"id": 2, "content-type": "multipart/mixed", "content": [
375 {"id": 3, "content-type": "message/rfc822", "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
376 {"id": 4, "content-type": "multipart/alternative", "content": [
377 {"id": 5, "content-type": "text/html", "content-length": 71},
378 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
379 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
380 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
381 {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}]}
383 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
385 test_begin_subtest "--format=json --part=1, message body"
386 notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
388 {"id": 1, "content-type": "multipart/signed", "content": [
389 {"id": 2, "content-type": "multipart/mixed", "content": [
390 {"id": 3, "content-type": "message/rfc822", "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
391 {"id": 4, "content-type": "multipart/alternative", "content": [
392 {"id": 5, "content-type": "text/html", "content-length": 71},
393 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
394 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
395 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
396 {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}
398 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
400 test_begin_subtest "--format=json --part=2, multipart/mixed"
401 notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
403 {"id": 2, "content-type": "multipart/mixed", "content": [
404 {"id": 3, "content-type": "message/rfc822", "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
405 {"id": 4, "content-type": "multipart/alternative", "content": [
406 {"id": 5, "content-type": "text/html", "content-length": 71},
407 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
408 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
409 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}
411 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
413 test_begin_subtest "--format=json --part=3, rfc822 part"
414 notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
416 {"id": 3, "content-type": "message/rfc822", "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
417 {"id": 4, "content-type": "multipart/alternative", "content": [
418 {"id": 5, "content-type": "text/html", "content-length": 71},
419 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}
421 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
423 test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"
424 notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
426 {"id": 4, "content-type": "multipart/alternative", "content": [
427 {"id": 5, "content-type": "text/html", "content-length": 71},
428 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}
430 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
432 test_begin_subtest "--format=json --part=5, rfc822's html part"
433 notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
435 {"id": 5, "content-type": "text/html", "content-length": 71}
437 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
439 test_begin_subtest "--format=json --part=6, rfc822's text part"
440 notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
442 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}
444 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
446 test_begin_subtest "--format=json --part=7, inline attachment"
447 notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
450 "content-type": "text/plain",
451 "filename": "attachment",
452 "content": "This is a text attachment.\n",
453 "content-disposition": "attachment"}
455 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
457 test_begin_subtest "--format=json --part=8, plain text part"
458 notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
460 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}
462 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
464 test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
465 notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
467 {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}
469 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
471 test_begin_subtest "--format=json --part=10, no part, expect error"
472 test_expect_success "notmuch show --format=json --part=10 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
474 test_begin_subtest "--format=raw"
475 notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
476 test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT
478 test_begin_subtest "--format=raw --part=0, full message"
479 notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
480 test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT
482 test_begin_subtest "--format=raw --part=1, message body"
483 test_subtest_broken_gmime_2
484 notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
485 test_expect_equal_file multipart_body OUTPUT
487 test_begin_subtest "--format=raw --part=2, multipart/mixed"
488 notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
490 Content-Type: multipart/mixed; boundary="=-=-="
493 Content-Type: message/rfc822
494 Content-Disposition: inline
496 From: Carl Worth <cworth@cworth.org>
497 To: cworth@cworth.org
498 Subject: html message
499 Date: Fri, 05 Jan 2001 15:42:57 +0000
500 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
501 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
503 Content-Type: multipart/alternative; boundary="==-=-=="
506 Content-Type: text/html
508 <p>This is an embedded message, with a multipart/alternative part.</p>
511 Content-Type: text/plain
513 This is an embedded message, with a multipart/alternative part.
518 Content-Disposition: attachment; filename=attachment
520 This is a text attachment.
524 And this message is signed.
530 test_expect_equal_file EXPECTED OUTPUT
532 test_begin_subtest "--format=raw --part=3, rfc822 part"
533 notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
534 test_expect_equal_file embedded_message OUTPUT
536 test_begin_subtest "--format=raw --part=4, rfc822's multipart"
537 test_subtest_broken_gmime_2
538 notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
539 test_expect_equal_file embedded_message_body OUTPUT
541 test_begin_subtest "--format=raw --part=5, rfc822's html part"
542 notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
544 <p>This is an embedded message, with a multipart/alternative part.</p>
546 test_expect_equal_file EXPECTED OUTPUT
548 test_begin_subtest "--format=raw --part=6, rfc822's text part"
549 notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
551 This is an embedded message, with a multipart/alternative part.
553 test_expect_equal_file EXPECTED OUTPUT
555 test_begin_subtest "--format=raw --part=7, inline attachment"
556 notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
558 This is a text attachment.
560 test_expect_equal_file EXPECTED OUTPUT
562 test_begin_subtest "--format=raw --part=8, plain text part"
563 notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
565 And this message is signed.
569 test_expect_equal_file EXPECTED OUTPUT
571 test_begin_subtest "--format=raw --part=9, pgp signature (unverified)"
572 notmuch show --format=raw --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
573 # output should *not* include newline
576 -----BEGIN PGP SIGNATURE-----
577 Version: GnuPG v1.4.11 (GNU/Linux)
579 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
580 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
582 -----END PGP SIGNATURE-----
584 test_expect_equal_file EXPECTED OUTPUT
586 test_begin_subtest "--format=raw --part=10, no part, expect error"
587 test_expect_success "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
589 test_begin_subtest "--format=mbox"
590 notmuch show --format=mbox 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
591 printf "From cworth@cworth.org Fri Jan 5 15:43:57 2001\n" >EXPECTED
592 cat "${MAIL_DIR}"/multipart >>EXPECTED
593 # mbox output is expected to include a blank line
595 test_expect_equal_file EXPECTED OUTPUT
597 test_begin_subtest "--format=mbox --part=1, incompatible, expect error"
598 test_expect_success "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
600 test_begin_subtest "'notmuch reply' to a multipart message"
601 notmuch reply 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
603 From: Notmuch Test Suite <test_suite@notmuchmail.org>
604 Subject: Re: Multipart message
605 To: Carl Worth <cworth@cworth.org>, cworth@cworth.org
606 In-Reply-To: <87liy5ap00.fsf@yoom.home.cworth.org>
607 References: <87liy5ap00.fsf@yoom.home.cworth.org>
609 On Fri, 05 Jan 2001 15:43:57 +0000, Carl Worth <cworth@cworth.org> wrote:
610 > From: Carl Worth <cworth@cworth.org>
611 > To: cworth@cworth.org
612 > Subject: html message
613 > Date: Fri, 05 Jan 2001 15:42:57 +0000
615 Non-text part: text/html
616 > This is an embedded message, with a multipart/alternative part.
617 > This is a text attachment.
618 > And this message is signed.
622 test_expect_equal_file EXPECTED OUTPUT
624 test_begin_subtest "'notmuch reply' to a multipart message with json format"
625 notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT
626 notmuch_json_show_sanitize <<EOF >EXPECTED
627 {"reply-headers": {"Subject": "Re: Multipart message",
628 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
629 "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",
630 "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",
631 "References": "<87liy5ap00.fsf@yoom.home.cworth.org>"},
632 "original": {"id": "XXXXX",
635 "filename": ["YYYYY"],
636 "timestamp": 978709437,
637 "date_relative": "2001-01-05",
638 "tags": ["attachment","inbox","signed","unread"],
639 "headers": {"Subject": "Multipart message",
640 "From": "Carl Worth <cworth@cworth.org>",
641 "To": "cworth@cworth.org",
642 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
644 "content-type": "multipart/signed",
645 "content": [{"id": 2,
646 "content-type": "multipart/mixed",
647 "content": [{"id": 3,
648 "content-type": "message/rfc822",
649 "content-disposition": "inline",
650 "content": [{"headers": {"Subject": "html message",
651 "From": "Carl Worth <cworth@cworth.org>",
652 "To": "cworth@cworth.org",
653 "Date": "Fri, 05 Jan 2001 15:42:57 +0000"},
655 "content-type": "multipart/alternative",
656 "content": [{"id": 5,
657 "content-type": "text/html",
658 "content-length": 71},
660 "content-type": "text/plain",
661 "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
663 "content-type": "text/plain",
664 "content-disposition": "attachment",
665 "filename": "attachment",
666 "content": "This is a text attachment.\n"},
668 "content-type": "text/plain",
669 "content": "And this message is signed.\n\n-Carl\n"}]},
671 "content-type": "application/pgp-signature",
672 "content-length": 197}]}]}}
674 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
676 test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"
677 notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
678 echo -n -e "\xEF\x0D\x0A" > crlf.expected
679 test_expect_equal_file crlf.out crlf.expected
682 # The ISO-8859-1 encoding of U+00BD is a single byte: octal 275
683 # (Portability note: Dollar-Single ($'...', ANSI C-style escape sequences)
684 # quoting works on bash, ksh, zsh, *BSD sh but not on dash, ash nor busybox sh)
685 readonly u_00bd_latin1=$'\275'
687 # The Unicode fraction symbol 1/2 is U+00BD and is encoded
688 # in UTF-8 as two bytes: octal 302 275
689 readonly u_00bd_utf8=$'\302\275'
691 cat <<EOF > ${MAIL_DIR}/include-html
692 From: A <a@example.com>
693 To: B <b@example.com>
694 Subject: html message
695 Date: Sat, 01 January 2000 00:00:00 +0000
696 Message-ID: <htmlmessage>
698 Content-Type: multipart/alternative; boundary="==-=="
701 Content-Type: text/html; charset=UTF-8
703 <p>0.5 equals ${u_00bd_utf8}</p>
706 Content-Type: text/html; charset=ISO-8859-1
708 <p>0.5 equals ${u_00bd_latin1}</p>
711 Content-Type: text/plain; charset=UTF-8
713 0.5 equals ${u_00bd_utf8}
718 notmuch new > /dev/null
723 [[[{"id": "htmlmessage", "match":true, "excluded": false, "date_relative":"2000-01-01",
724 "timestamp": 946684800,
725 "filename": ["${MAIL_DIR}/include-html"],
726 "tags": ["inbox", "unread"],
727 "headers": { "Date": "Sat, 01 Jan 2000 00:00:00 +0000", "From": "A <a@example.com>",
728 "Subject": "html message", "To": "B <b@example.com>"},
730 "content-type": "multipart/alternative", "id": 1,
734 cat_expected_head > EXPECTED.nohtml
735 cat <<EOF >> EXPECTED.nohtml
737 { "id": 2, "content-charset": "UTF-8", "content-length": 21, "content-type": "text/html"},
738 { "id": 3, "content-charset": "ISO-8859-1", "content-length": 20, "content-type": "text/html"},
739 { "id": 4, "content-type": "text/plain", "content": "0.5 equals \\u00bd\\n"}
743 # Both the UTF-8 and ISO-8859-1 part should have U+00BD
744 cat_expected_head > EXPECTED.withhtml
745 cat <<EOF >> EXPECTED.withhtml
747 { "id": 2, "content-type": "text/html", "content": "<p>0.5 equals \\u00bd</p>\\n"},
748 { "id": 3, "content-type": "text/html", "content": "<p>0.5 equals \\u00bd</p>\\n"},
749 { "id": 4, "content-type": "text/plain", "content": "0.5 equals \\u00bd\\n"}
753 test_begin_subtest "html parts excluded by default"
754 notmuch show --format=json id:htmlmessage > OUTPUT
755 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.nohtml)"
757 test_begin_subtest "html parts included"
758 notmuch show --format=json --include-html id:htmlmessage > OUTPUT
759 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)"
761 test_begin_subtest "indexes mime-type #1"
762 output=$(notmuch search mimetype:application/unique_identifier | notmuch_search_sanitize)
763 test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
765 test_begin_subtest "indexes mime-type #2"
766 output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize)
767 test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
769 test_begin_subtest "indexes mime-type #3"
770 output=$(notmuch search from:todd and mimetype:multipart/alternative | notmuch_search_sanitize)
771 test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
773 test_begin_subtest "case of Content-Disposition doesn't matter for indexing"
774 cat <<EOF > ${MAIL_DIR}/content-disposition
775 Return-path: <david@tethera.net>
776 Envelope-to: david@tethera.net
777 Delivery-date: Sun, 04 Oct 2015 09:16:03 -0300
778 Received: from gitolite.debian.net ([87.98.215.224])
779 by yantan.tethera.net with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128)
781 (envelope-from <david@tethera.net>)
783 for david@tethera.net; Sun, 04 Oct 2015 09:16:03 -0300
784 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
785 (envelope-from <david@tethera.net>)
786 id 1ZiiC8-0002Rz-Uf; Sun, 04 Oct 2015 12:15:12 +0000
787 Received: (nullmailer pid 28621 invoked by uid 1000); Sun, 04 Oct 2015
789 From: David Bremner <david@tethera.net>
790 To: David Bremner <david@tethera.net>
791 Subject: test attachment
792 User-Agent: Notmuch/0.20.2+93~g33c8777 (http://notmuchmail.org) Emacs/24.5.1
793 (x86_64-pc-linux-gnu)
794 Date: Sun, 04 Oct 2015 09:14:53 -0300
795 Message-ID: <87io6m96f6.fsf@zancas.localnet>
797 Content-Type: multipart/mixed; boundary="=-=-="
800 Content-Type: text/plain
801 Content-Disposition: ATTACHMENT; filename=hello.txt
802 Content-Description: this is a very exciting file
807 Content-Type: text/plain
823 notmuch search --output=tags id:87io6m96f6.fsf@zancas.localnet > OUTPUT
824 test_expect_equal_file EXPECTED OUTPUT