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 --include-html --part=5, rfc822's html part"
329 notmuch show --format=text --include-html --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
331 \fpart{ ID: 5, Content-type: text/html
332 <p>This is an embedded message, with a multipart/alternative part.</p>
335 test_expect_equal_file EXPECTED OUTPUT
337 test_begin_subtest "--format=text --part=6, rfc822's text part"
338 notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
340 \fpart{ ID: 6, Content-type: text/plain
341 This is an embedded message, with a multipart/alternative part.
344 test_expect_equal_file EXPECTED OUTPUT
346 test_begin_subtest "--format=text --part=7, inline attachment"
347 notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
349 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
350 This is a text attachment.
353 test_expect_equal_file EXPECTED OUTPUT
355 test_begin_subtest "--format=text --part=8, plain text part"
356 notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
358 \fpart{ ID: 8, Content-type: text/plain
359 And this message is signed.
364 test_expect_equal_file EXPECTED OUTPUT
366 test_begin_subtest "--format=text --part=9, pgp signature (unverified)"
367 notmuch show --format=text --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
369 \fpart{ ID: 9, Content-type: application/pgp-signature
370 Non-text part: application/pgp-signature
373 test_expect_equal_file EXPECTED OUTPUT
375 test_begin_subtest "--format=text --part=8, no part, expect error"
376 test_expect_success "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
378 test_begin_subtest "--format=json --part=0, full message"
379 notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT
381 {"id": "XXXXX", "crypto": {}, "match": true, "excluded": false, "filename": ["YYYYY"], "timestamp": 42, "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": "GENERATED_DATE"}, "body": [
382 {"id": 1, "content-type": "multipart/signed", "content": [
383 {"id": 2, "content-type": "multipart/mixed", "content": [
384 {"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": "GENERATED_DATE"}, "body": [
385 {"id": 4, "content-type": "multipart/alternative", "content": [
386 {"id": 5, "content-type": "text/html", "content-length": "NONZERO"},
387 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
388 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
389 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
390 {"id": 9, "content-type": "application/pgp-signature", "content-length": "NONZERO"}]}]}
392 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
394 test_begin_subtest "--format=json --part=1, message body"
395 notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
397 {"id": 1, "content-type": "multipart/signed", "content": [
398 {"id": 2, "content-type": "multipart/mixed", "content": [
399 {"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": [
400 {"id": 4, "content-type": "multipart/alternative", "content": [
401 {"id": 5, "content-type": "text/html", "content-length": 71},
402 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
403 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
404 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
405 {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}
407 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
409 test_begin_subtest "--format=json --part=2, multipart/mixed"
410 notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
412 {"id": 2, "content-type": "multipart/mixed", "content": [
413 {"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": [
414 {"id": 4, "content-type": "multipart/alternative", "content": [
415 {"id": 5, "content-type": "text/html", "content-length": 71},
416 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
417 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
418 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}
420 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
422 test_begin_subtest "--format=json --part=3, rfc822 part"
423 notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
425 {"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": [
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=4, rfc822's multipart/alternative"
433 notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
435 {"id": 4, "content-type": "multipart/alternative", "content": [
436 {"id": 5, "content-type": "text/html", "content-length": 71},
437 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}
439 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
441 test_begin_subtest "--format=json --part=5, rfc822's html part"
442 notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
444 {"id": 5, "content-type": "text/html", "content-length": 71}
446 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
448 test_begin_subtest "--format=json --part=6, rfc822's text part"
449 notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
451 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}
453 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
455 test_begin_subtest "--format=json --part=7, inline attachment"
456 notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
459 "content-type": "text/plain",
460 "filename": "attachment",
461 "content": "This is a text attachment.\n",
462 "content-disposition": "attachment"}
464 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
466 test_begin_subtest "--format=json --part=8, plain text part"
467 notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
469 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}
471 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
473 test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
474 notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
476 {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}
478 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
480 test_begin_subtest "--format=json --part=10, no part, expect error"
481 test_expect_success "notmuch show --format=json --part=10 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
483 test_begin_subtest "--format=raw"
484 notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
485 test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT
487 test_begin_subtest "--format=raw --part=0, full message"
488 notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT
489 test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT
491 test_begin_subtest "--format=raw --part=1, message body"
492 notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
493 test_expect_equal_file multipart_body OUTPUT
495 test_begin_subtest "--format=raw --part=2, multipart/mixed"
496 notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
498 Content-Type: multipart/mixed; boundary="=-=-="
501 Content-Type: message/rfc822
502 Content-Disposition: inline
504 From: Carl Worth <cworth@cworth.org>
505 To: cworth@cworth.org
506 Subject: html message
507 Date: Fri, 05 Jan 2001 15:42:57 +0000
508 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
509 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
511 Content-Type: multipart/alternative; boundary="==-=-=="
514 Content-Type: text/html
516 <p>This is an embedded message, with a multipart/alternative part.</p>
519 Content-Type: text/plain
521 This is an embedded message, with a multipart/alternative part.
526 Content-Disposition: attachment; filename=attachment
528 This is a text attachment.
532 And this message is signed.
538 test_expect_equal_file EXPECTED OUTPUT
540 test_begin_subtest "--format=raw --part=3, rfc822 part"
541 notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
542 test_expect_equal_file embedded_message OUTPUT
544 test_begin_subtest "--format=raw --part=4, rfc822's multipart"
545 notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
546 test_expect_equal_file embedded_message_body OUTPUT
548 test_begin_subtest "--format=raw --part=5, rfc822's html part"
549 notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
551 <p>This is an embedded message, with a multipart/alternative part.</p>
553 test_expect_equal_file EXPECTED OUTPUT
555 test_begin_subtest "--format=raw --part=6, rfc822's text part"
556 notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
558 This is an embedded message, with a multipart/alternative part.
560 test_expect_equal_file EXPECTED OUTPUT
562 test_begin_subtest "--format=raw --part=7, inline attachment"
563 notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
565 This is a text attachment.
567 test_expect_equal_file EXPECTED OUTPUT
569 test_begin_subtest "--format=raw --part=8, plain text part"
570 notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
572 And this message is signed.
576 test_expect_equal_file EXPECTED OUTPUT
578 test_begin_subtest "--format=raw --part=9, pgp signature (unverified)"
579 notmuch show --format=raw --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
580 # output should *not* include newline
583 -----BEGIN PGP SIGNATURE-----
584 Version: GnuPG v1.4.11 (GNU/Linux)
586 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
587 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
589 -----END PGP SIGNATURE-----
591 test_expect_equal_file EXPECTED OUTPUT
593 test_begin_subtest "--format=raw --part=10, no part, expect error"
594 test_expect_success "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
596 test_begin_subtest "--format=mbox"
597 notmuch show --format=mbox 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
598 printf "From cworth@cworth.org Fri Jan 5 15:43:57 2001\n" >EXPECTED
599 cat "${MAIL_DIR}"/multipart >>EXPECTED
600 # mbox output is expected to include a blank line
602 test_expect_equal_file EXPECTED OUTPUT
604 test_begin_subtest "--format=mbox --part=1, incompatible, expect error"
605 test_expect_success "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
607 test_begin_subtest "'notmuch reply' to a multipart message"
608 notmuch reply 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
610 From: Notmuch Test Suite <test_suite@notmuchmail.org>
611 Subject: Re: Multipart message
612 To: Carl Worth <cworth@cworth.org>, cworth@cworth.org
613 In-Reply-To: <87liy5ap00.fsf@yoom.home.cworth.org>
614 References: <87liy5ap00.fsf@yoom.home.cworth.org>
616 On Fri, 05 Jan 2001 15:43:57 +0000, Carl Worth <cworth@cworth.org> wrote:
617 > From: Carl Worth <cworth@cworth.org>
618 > To: cworth@cworth.org
619 > Subject: html message
620 > Date: Fri, 05 Jan 2001 15:42:57 +0000
622 Non-text part: text/html
623 > This is an embedded message, with a multipart/alternative part.
624 > This is a text attachment.
625 > And this message is signed.
629 test_expect_equal_file EXPECTED OUTPUT
631 test_begin_subtest "'notmuch reply' to a multipart message with json format"
632 notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT
633 notmuch_json_show_sanitize <<EOF >EXPECTED
634 {"reply-headers": {"Subject": "Re: Multipart message",
635 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
636 "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",
637 "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",
638 "References": "<87liy5ap00.fsf@yoom.home.cworth.org>"},
639 "original": {"id": "XXXXX",
643 "filename": ["YYYYY"],
644 "timestamp": 978709437,
645 "date_relative": "2001-01-05",
646 "tags": ["attachment","inbox","signed","unread"],
647 "headers": {"Subject": "Multipart message",
648 "From": "Carl Worth <cworth@cworth.org>",
649 "To": "cworth@cworth.org",
650 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
652 "content-type": "multipart/signed",
653 "content": [{"id": 2,
654 "content-type": "multipart/mixed",
655 "content": [{"id": 3,
656 "content-type": "message/rfc822",
657 "content-disposition": "inline",
658 "content": [{"headers": {"Subject": "html message",
659 "From": "Carl Worth <cworth@cworth.org>",
660 "To": "cworth@cworth.org",
661 "Date": "Fri, 05 Jan 2001 15:42:57 +0000"},
663 "content-type": "multipart/alternative",
664 "content": [{"id": 5,
665 "content-type": "text/html",
666 "content-length": 71},
668 "content-type": "text/plain",
669 "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
671 "content-type": "text/plain",
672 "content-disposition": "attachment",
673 "filename": "attachment",
674 "content": "This is a text attachment.\n"},
676 "content-type": "text/plain",
677 "content": "And this message is signed.\n\n-Carl\n"}]},
679 "content-type": "application/pgp-signature",
680 "content-length": 197}]}]}}
682 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
684 test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"
685 notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
686 printf "\xEF\x0D\x0A" > crlf.expected
687 test_expect_equal_file crlf.out crlf.expected
690 # The ISO-8859-1 encoding of U+00BD is a single byte: octal 275
691 # (Portability note: Dollar-Single ($'...', ANSI C-style escape sequences)
692 # quoting works on bash, ksh, zsh, *BSD sh but not on dash, ash nor busybox sh)
693 readonly u_00bd_latin1=$'\275'
695 # The Unicode fraction symbol 1/2 is U+00BD and is encoded
696 # in UTF-8 as two bytes: octal 302 275
697 readonly u_00bd_utf8=$'\302\275'
699 cat <<EOF > ${MAIL_DIR}/include-html
700 From: A <a@example.com>
701 To: B <b@example.com>
702 Subject: html message
703 Date: Sat, 01 January 2000 00:00:00 +0000
704 Message-ID: <htmlmessage>
706 Content-Type: multipart/alternative; boundary="==-=="
709 Content-Type: text/html; charset=UTF-8
711 <p>0.5 equals ${u_00bd_utf8}</p>
714 Content-Type: text/html; charset=ISO-8859-1
716 <p>0.5 equals ${u_00bd_latin1}</p>
719 Content-Type: text/plain; charset=UTF-8
721 0.5 equals ${u_00bd_utf8}
726 notmuch new > /dev/null
728 cat_expected_head () {
730 [[[{"id": "XXXXX", "match":true, "excluded": false, "date_relative":"2000-01-01",
732 "timestamp": 946684800,
733 "filename": ["YYYYY"],
734 "tags": ["inbox", "unread"],
735 "headers": { "Date": "Sat, 01 Jan 2000 00:00:00 +0000", "From": "A <a@example.com>",
736 "Subject": "html message", "To": "B <b@example.com>"},
738 "content-type": "multipart/alternative", "id": 1,
742 cat_expected_head > EXPECTED.nohtml
743 cat <<EOF >> EXPECTED.nohtml
745 { "id": 2, "content-charset": "UTF-8", "content-length": "NONZERO", "content-type": "text/html"},
746 { "id": 3, "content-charset": "ISO-8859-1", "content-length": "NONZERO", "content-type": "text/html"},
747 { "id": 4, "content-type": "text/plain", "content": "0.5 equals \\u00bd\\n"}
751 # Both the UTF-8 and ISO-8859-1 part should have U+00BD
752 cat_expected_head > EXPECTED.withhtml
753 cat <<EOF >> EXPECTED.withhtml
755 { "id": 2, "content-type": "text/html", "content": "<p>0.5 equals \\u00bd</p>\\n"},
756 { "id": 3, "content-type": "text/html", "content": "<p>0.5 equals \\u00bd</p>\\n"},
757 { "id": 4, "content-type": "text/plain", "content": "0.5 equals \\u00bd\\n"}
761 test_begin_subtest "html parts excluded by default"
762 notmuch show --format=json id:htmlmessage | notmuch_json_show_sanitize > OUTPUT
763 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.nohtml)"
765 test_begin_subtest "html parts included"
766 notmuch show --format=json --include-html id:htmlmessage | notmuch_json_show_sanitize > OUTPUT
767 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)"
769 test_begin_subtest "indexes mime-type #1"
770 output=$(notmuch search mimetype:application/unique_identifier | 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 "indexes mime-type #2"
774 output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize)
775 test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
777 test_begin_subtest "indexes mime-type #3"
778 output=$(notmuch search from:todd and mimetype:multipart/alternative | notmuch_search_sanitize)
779 test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
781 test_begin_subtest "case of Content-Disposition doesn't matter for indexing"
782 cat <<EOF > ${MAIL_DIR}/content-disposition
783 Return-path: <david@tethera.net>
784 Envelope-to: david@tethera.net
785 Delivery-date: Sun, 04 Oct 2015 09:16:03 -0300
786 Received: from gitolite.debian.net ([87.98.215.224])
787 by yantan.tethera.net with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128)
789 (envelope-from <david@tethera.net>)
791 for david@tethera.net; Sun, 04 Oct 2015 09:16:03 -0300
792 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
793 (envelope-from <david@tethera.net>)
794 id 1ZiiC8-0002Rz-Uf; Sun, 04 Oct 2015 12:15:12 +0000
795 Received: (nullmailer pid 28621 invoked by uid 1000); Sun, 04 Oct 2015
797 From: David Bremner <david@tethera.net>
798 To: David Bremner <david@tethera.net>
799 Subject: test attachment
800 User-Agent: Notmuch/0.20.2+93~g33c8777 (http://notmuchmail.org) Emacs/24.5.1
801 (x86_64-pc-linux-gnu)
802 Date: Sun, 04 Oct 2015 09:14:53 -0300
803 Message-ID: <87io6m96f6.fsf@zancas.localnet>
805 Content-Type: multipart/mixed; boundary="=-=-="
808 Content-Type: text/plain
809 Content-Disposition: ATTACHMENT; filename=hello.txt
810 Content-Description: this is a very exciting file
815 Content-Type: text/plain
831 notmuch search --output=tags id:87io6m96f6.fsf@zancas.localnet > OUTPUT
832 test_expect_equal_file EXPECTED OUTPUT