2 test_description="output of multipart message"
3 . ./test-lib.sh || exit 1
5 cat <<EOF > embedded_message
6 From: Carl Worth <cworth@cworth.org>
9 Date: Fri, 05 Jan 2001 15:42:57 +0000
10 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
11 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
13 Content-Type: multipart/alternative; boundary="==-=-=="
16 Content-Type: text/html
18 <p>This is an embedded message, with a multipart/alternative part.</p>
21 Content-Type: text/plain
23 This is an embedded message, with a multipart/alternative part.
28 cat <<EOF > ${MAIL_DIR}/multipart
29 From: Carl Worth <cworth@cworth.org>
31 Subject: Multipart message
32 Date: Fri, 05 Jan 2001 15:43:57 +0000
33 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
34 Message-ID: <87liy5ap00.fsf@yoom.home.cworth.org>
36 Content-Type: multipart/signed; boundary="==-=-=";
37 micalg=pgp-sha1; protocol="application/pgp-signature"
40 Content-Type: multipart/mixed; boundary="=-=-="
43 Content-Type: message/rfc822
44 Content-Disposition: inline
47 cat embedded_message >> ${MAIL_DIR}/multipart
48 cat <<EOF >> ${MAIL_DIR}/multipart
51 Content-Disposition: attachment; filename=attachment
53 This is a text attachment.
57 And this message is signed.
64 Content-Type: application/pgp-signature
66 -----BEGIN PGP SIGNATURE-----
67 Version: GnuPG v1.4.11 (GNU/Linux)
69 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
70 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
72 -----END PGP SIGNATURE-----
76 cat <<EOF > ${MAIL_DIR}/base64-part-with-crlf
77 From: Carl Worth <cworth@cworth.org>
79 Subject: Test message with a BASE64 encoded binary containing CRLF pair
80 Date: Fri, 05 Jan 2001 15:43:57 +0000
81 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
82 Message-ID: <base64-part-with-crlf>
84 Content-Type: multipart/mixed; boundary="==-=-=";
88 The attached BASE64-encoded part expands to a binary containing a CRLF
89 pair (that is one bye of 0x0D followed by one byte of 0x0A). This is
90 designed to ensure that notmuch is not corrupting the output of this
91 part by converting the CRLF pair to an LF only (as would be appropriate
92 for display of a text part on a Linux system, for example).
94 The part should be a 3-byte file with the following sequence of 3
100 Content-Type: application/octet-stream
101 Content-Disposition: attachment; filename=crlf.bin
102 Content-Transfer-Encoding: base64
108 cat <<EOF > content_types
109 From: Todd <todd@example.com>
111 Subject: odd content types
112 Date: Mon, 12 Jan 2014 18:12:32 +0000
113 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
114 Message-ID: <KfjfO2WJBw2hrV2p0gjT@example.com>
116 Content-Type: multipart/alternative; boundary="==-=-=="
119 Content-Type: application/unique_identifier
121 <p>This is an embedded message, with a multipart/alternative part.</p>
124 Content-Type: text/some_other_identifier
126 This is an embedded message, with a multipart/alternative part.
130 cat content_types >> ${MAIL_DIR}/odd_content_type
131 notmuch new > /dev/null
133 test_begin_subtest "--format=text --part=0, full message"
134 notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
136 \fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 excluded:0 filename:${MAIL_DIR}/multipart
138 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
139 Subject: Multipart message
140 From: Carl Worth <cworth@cworth.org>
141 To: cworth@cworth.org
142 Date: Fri, 05 Jan 2001 15:43:57 +0000
145 \fpart{ ID: 1, Content-type: multipart/signed
146 \fpart{ ID: 2, Content-type: multipart/mixed
147 \fpart{ ID: 3, Content-type: message/rfc822
149 Subject: html message
150 From: Carl Worth <cworth@cworth.org>
151 To: cworth@cworth.org
152 Date: Fri, 05 Jan 2001 15:42:57 +0000
155 \fpart{ ID: 4, Content-type: multipart/alternative
156 \fpart{ ID: 5, Content-type: text/html
157 Non-text part: text/html
159 \fpart{ ID: 6, Content-type: text/plain
160 This is an embedded message, with a multipart/alternative part.
165 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
166 This is a text attachment.
168 \fpart{ ID: 8, Content-type: text/plain
169 And this message is signed.
174 \fpart{ ID: 9, Content-type: application/pgp-signature
175 Non-text part: application/pgp-signature
181 test_expect_equal_file OUTPUT EXPECTED
183 test_begin_subtest "--format=text --part=1, message body"
184 notmuch show --format=text --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
186 \fpart{ ID: 1, Content-type: multipart/signed
187 \fpart{ ID: 2, Content-type: multipart/mixed
188 \fpart{ ID: 3, Content-type: message/rfc822
190 Subject: html message
191 From: Carl Worth <cworth@cworth.org>
192 To: cworth@cworth.org
193 Date: Fri, 05 Jan 2001 15:42:57 +0000
196 \fpart{ ID: 4, Content-type: multipart/alternative
197 \fpart{ ID: 5, Content-type: text/html
198 Non-text part: text/html
200 \fpart{ ID: 6, Content-type: text/plain
201 This is an embedded message, with a multipart/alternative part.
206 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
207 This is a text attachment.
209 \fpart{ ID: 8, Content-type: text/plain
210 And this message is signed.
215 \fpart{ ID: 9, Content-type: application/pgp-signature
216 Non-text part: application/pgp-signature
220 test_expect_equal_file OUTPUT EXPECTED
222 test_begin_subtest "--format=text --part=2, multipart/mixed"
223 notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
225 \fpart{ ID: 2, Content-type: multipart/mixed
226 \fpart{ ID: 3, Content-type: message/rfc822
228 Subject: html message
229 From: Carl Worth <cworth@cworth.org>
230 To: cworth@cworth.org
231 Date: Fri, 05 Jan 2001 15:42:57 +0000
234 \fpart{ ID: 4, Content-type: multipart/alternative
235 \fpart{ ID: 5, Content-type: text/html
236 Non-text part: text/html
238 \fpart{ ID: 6, Content-type: text/plain
239 This is an embedded message, with a multipart/alternative part.
244 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
245 This is a text attachment.
247 \fpart{ ID: 8, Content-type: text/plain
248 And this message is signed.
254 test_expect_equal_file OUTPUT EXPECTED
256 test_begin_subtest "--format=text --part=3, rfc822 part"
257 notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
259 \fpart{ ID: 3, Content-type: message/rfc822
261 Subject: html message
262 From: Carl Worth <cworth@cworth.org>
263 To: cworth@cworth.org
264 Date: Fri, 05 Jan 2001 15:42:57 +0000
267 \fpart{ ID: 4, Content-type: multipart/alternative
268 \fpart{ ID: 5, Content-type: text/html
269 Non-text part: text/html
271 \fpart{ ID: 6, Content-type: text/plain
272 This is an embedded message, with a multipart/alternative part.
278 test_expect_equal_file OUTPUT EXPECTED
280 test_begin_subtest "--format=text --part=4, rfc822's multipart"
281 notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
283 \fpart{ ID: 4, Content-type: multipart/alternative
284 \fpart{ ID: 5, Content-type: text/html
285 Non-text part: text/html
287 \fpart{ ID: 6, Content-type: text/plain
288 This is an embedded message, with a multipart/alternative part.
292 test_expect_equal_file OUTPUT EXPECTED
294 test_begin_subtest "--format=text --part=5, rfc822's html part"
295 notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
297 \fpart{ ID: 5, Content-type: text/html
298 Non-text part: text/html
301 test_expect_equal_file OUTPUT EXPECTED
303 test_begin_subtest "--format=text --part=6, rfc822's text part"
304 notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
306 \fpart{ ID: 6, Content-type: text/plain
307 This is an embedded message, with a multipart/alternative part.
310 test_expect_equal_file OUTPUT EXPECTED
312 test_begin_subtest "--format=text --part=7, inline attachement"
313 notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
315 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
316 This is a text attachment.
319 test_expect_equal_file OUTPUT EXPECTED
321 test_begin_subtest "--format=text --part=8, plain text part"
322 notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
324 \fpart{ ID: 8, Content-type: text/plain
325 And this message is signed.
330 test_expect_equal_file OUTPUT EXPECTED
332 test_begin_subtest "--format=text --part=9, pgp signature (unverified)"
333 notmuch show --format=text --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
335 \fpart{ ID: 9, Content-type: application/pgp-signature
336 Non-text part: application/pgp-signature
339 test_expect_equal_file OUTPUT EXPECTED
341 test_expect_success \
342 "--format=text --part=8, no part, expect error" \
343 "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
345 test_begin_subtest "--format=json --part=0, full message"
346 notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
348 {"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": [
349 {"id": 1, "content-type": "multipart/signed", "content": [
350 {"id": 2, "content-type": "multipart/mixed", "content": [
351 {"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": [
352 {"id": 4, "content-type": "multipart/alternative", "content": [
353 {"id": 5, "content-type": "text/html", "content-length": 71},
354 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
355 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
356 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
357 {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}]}
359 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
361 test_begin_subtest "--format=json --part=1, message body"
362 notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
364 {"id": 1, "content-type": "multipart/signed", "content": [
365 {"id": 2, "content-type": "multipart/mixed", "content": [
366 {"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": [
367 {"id": 4, "content-type": "multipart/alternative", "content": [
368 {"id": 5, "content-type": "text/html", "content-length": 71},
369 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
370 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
371 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
372 {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}
374 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
376 test_begin_subtest "--format=json --part=2, multipart/mixed"
377 notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
379 {"id": 2, "content-type": "multipart/mixed", "content": [
380 {"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": [
381 {"id": 4, "content-type": "multipart/alternative", "content": [
382 {"id": 5, "content-type": "text/html", "content-length": 71},
383 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
384 {"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"},
385 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}
387 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
389 test_begin_subtest "--format=json --part=3, rfc822 part"
390 notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
392 {"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": [
393 {"id": 4, "content-type": "multipart/alternative", "content": [
394 {"id": 5, "content-type": "text/html", "content-length": 71},
395 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}
397 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
399 test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"
400 notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
402 {"id": 4, "content-type": "multipart/alternative", "content": [
403 {"id": 5, "content-type": "text/html", "content-length": 71},
404 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}
406 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
408 test_begin_subtest "--format=json --part=5, rfc822's html part"
409 notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
411 {"id": 5, "content-type": "text/html", "content-length": 71}
413 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
415 test_begin_subtest "--format=json --part=6, rfc822's text part"
416 notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
418 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}
420 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
422 test_begin_subtest "--format=json --part=7, inline attachment"
423 notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
426 "content-type": "text/plain",
427 "filename": "attachment",
428 "content": "This is a text attachment.\n",
429 "content-disposition": "attachment"}
431 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
433 test_begin_subtest "--format=json --part=8, plain text part"
434 notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
436 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}
438 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
440 test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
441 notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
443 {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}
445 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
447 test_expect_success \
448 "--format=json --part=10, no part, expect error" \
449 "notmuch show --format=json --part=10 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
451 test_begin_subtest "--format=raw"
452 notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
453 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
455 test_begin_subtest "--format=raw --part=0, full message"
456 notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
457 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
459 test_begin_subtest "--format=raw --part=1, message body"
460 notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
461 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
463 test_begin_subtest "--format=raw --part=2, multipart/mixed"
464 notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
466 Content-Type: multipart/mixed; boundary="=-=-="
469 Content-Type: message/rfc822
470 Content-Disposition: inline
472 From: Carl Worth <cworth@cworth.org>
473 To: cworth@cworth.org
474 Subject: html message
475 Date: Fri, 05 Jan 2001 15:42:57 +0000
476 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
477 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
479 Content-Type: multipart/alternative; boundary="==-=-=="
482 Content-Type: text/html
484 <p>This is an embedded message, with a multipart/alternative part.</p>
487 Content-Type: text/plain
489 This is an embedded message, with a multipart/alternative part.
494 Content-Disposition: attachment; filename=attachment
496 This is a text attachment.
500 And this message is signed.
506 test_expect_equal_file OUTPUT EXPECTED
508 test_begin_subtest "--format=raw --part=3, rfc822 part"
509 notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
510 test_expect_equal_file OUTPUT embedded_message
512 test_begin_subtest "--format=raw --part=4, rfc822's multipart"
513 notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
515 From: Carl Worth <cworth@cworth.org>
516 To: cworth@cworth.org
517 Subject: html message
518 Date: Fri, 05 Jan 2001 15:42:57 +0000
519 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
520 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
522 Content-Type: multipart/alternative; boundary="==-=-=="
525 Content-Type: text/html
527 <p>This is an embedded message, with a multipart/alternative part.</p>
530 Content-Type: text/plain
532 This is an embedded message, with a multipart/alternative part.
536 test_expect_equal_file OUTPUT EXPECTED
538 test_begin_subtest "--format=raw --part=5, rfc822's html part"
539 notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
541 <p>This is an embedded message, with a multipart/alternative part.</p>
543 test_expect_equal_file OUTPUT EXPECTED
545 test_begin_subtest "--format=raw --part=6, rfc822's text part"
546 notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
548 This is an embedded message, with a multipart/alternative part.
550 test_expect_equal_file OUTPUT EXPECTED
552 test_begin_subtest "--format=raw --part=7, inline attachment"
553 notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
555 This is a text attachment.
557 test_expect_equal_file OUTPUT EXPECTED
559 test_begin_subtest "--format=raw --part=8, plain text part"
560 notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
562 And this message is signed.
566 test_expect_equal_file OUTPUT EXPECTED
568 test_begin_subtest "--format=raw --part=9, pgp signature (unverified)"
569 notmuch show --format=raw --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
570 # output should *not* include newline
573 -----BEGIN PGP SIGNATURE-----
574 Version: GnuPG v1.4.11 (GNU/Linux)
576 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
577 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
579 -----END PGP SIGNATURE-----
581 test_expect_equal_file OUTPUT EXPECTED
583 test_expect_success \
584 "--format=raw --part=10, no part, expect error" \
585 "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
587 test_begin_subtest "--format=mbox"
588 notmuch show --format=mbox 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
589 printf "From cworth@cworth.org Fri Jan 5 15:43:57 2001\n" >EXPECTED
590 cat "${MAIL_DIR}"/multipart >>EXPECTED
591 # mbox output is expected to include a blank line
593 test_expect_equal_file OUTPUT EXPECTED
595 test_expect_success \
596 "--format=mbox --part=1, incompatible, expect error" \
597 "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
599 test_begin_subtest "'notmuch reply' to a multipart message"
600 notmuch reply 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
602 From: Notmuch Test Suite <test_suite@notmuchmail.org>
603 Subject: Re: Multipart message
604 To: Carl Worth <cworth@cworth.org>, cworth@cworth.org
605 In-Reply-To: <87liy5ap00.fsf@yoom.home.cworth.org>
606 References: <87liy5ap00.fsf@yoom.home.cworth.org>
608 On Fri, 05 Jan 2001 15:43:57 +0000, Carl Worth <cworth@cworth.org> wrote:
609 > From: Carl Worth <cworth@cworth.org>
610 > To: cworth@cworth.org
611 > Subject: html message
612 > Date: Fri, 05 Jan 2001 15:42:57 +0000
614 Non-text part: text/html
615 > This is an embedded message, with a multipart/alternative part.
616 > This is a text attachment.
617 > And this message is signed.
621 test_expect_equal_file OUTPUT EXPECTED
623 test_begin_subtest "'notmuch reply' to a multipart message with json format"
624 notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT
625 notmuch_json_show_sanitize <<EOF >EXPECTED
626 {"reply-headers": {"Subject": "Re: Multipart message",
627 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
628 "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",
629 "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",
630 "References": "<87liy5ap00.fsf@yoom.home.cworth.org>"},
631 "original": {"id": "XXXXX",
634 "filename": ["YYYYY"],
635 "timestamp": 978709437,
636 "date_relative": "2001-01-05",
637 "tags": ["attachment","inbox","signed","unread"],
638 "headers": {"Subject": "Multipart message",
639 "From": "Carl Worth <cworth@cworth.org>",
640 "To": "cworth@cworth.org",
641 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
643 "content-type": "multipart/signed",
644 "content": [{"id": 2,
645 "content-type": "multipart/mixed",
646 "content": [{"id": 3,
647 "content-type": "message/rfc822",
648 "content-disposition": "inline",
649 "content": [{"headers": {"Subject": "html message",
650 "From": "Carl Worth <cworth@cworth.org>",
651 "To": "cworth@cworth.org",
652 "Date": "Fri, 05 Jan 2001 15:42:57 +0000"},
654 "content-type": "multipart/alternative",
655 "content": [{"id": 5,
656 "content-type": "text/html",
657 "content-length": 71},
659 "content-type": "text/plain",
660 "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
662 "content-type": "text/plain",
663 "content-disposition": "attachment",
664 "filename": "attachment",
665 "content": "This is a text attachment.\n"},
667 "content-type": "text/plain",
668 "content": "And this message is signed.\n\n-Carl\n"}]},
670 "content-type": "application/pgp-signature",
671 "content-length": 197}]}]}}
673 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
675 test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"
676 notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
677 echo -n -e "\xEF\x0D\x0A" > crlf.expected
678 test_expect_equal_file crlf.out crlf.expected
681 # The ISO-8859-1 encoding of U+00BD is a single byte: octal 275
682 # (Portability note: Dollar-Single ($'...', ANSI C-style escape sequences)
683 # quoting works on bash, ksh, zsh, *BSD sh but not on dash, ash nor busybox sh)
684 readonly u_00bd_latin1=$'\275'
686 # The Unicode fraction symbol 1/2 is U+00BD and is encoded
687 # in UTF-8 as two bytes: octal 302 275
688 readonly u_00bd_utf8=$'\302\275'
690 cat <<EOF > ${MAIL_DIR}/include-html
691 From: A <a@example.com>
692 To: B <b@example.com>
693 Subject: html message
694 Date: Sat, 01 January 2000 00:00:00 +0000
695 Message-ID: <htmlmessage>
697 Content-Type: multipart/alternative; boundary="==-=="
700 Content-Type: text/html; charset=UTF-8
702 <p>0.5 equals ${u_00bd_utf8}</p>
705 Content-Type: text/html; charset=ISO-8859-1
707 <p>0.5 equals ${u_00bd_latin1}</p>
710 Content-Type: text/plain; charset=UTF-8
712 0.5 equals ${u_00bd_utf8}
717 notmuch new > /dev/null
722 [[[{"id": "htmlmessage", "match":true, "excluded": false, "date_relative":"2000-01-01",
723 "timestamp": 946684800,
724 "filename": ["${MAIL_DIR}/include-html"],
725 "tags": ["inbox", "unread"],
726 "headers": { "Date": "Sat, 01 Jan 2000 00:00:00 +0000", "From": "A <a@example.com>",
727 "Subject": "html message", "To": "B <b@example.com>"},
729 "content-type": "multipart/alternative", "id": 1,
733 cat_expected_head > EXPECTED.nohtml
734 cat <<EOF >> EXPECTED.nohtml
736 { "id": 2, "content-charset": "UTF-8", "content-length": 21, "content-type": "text/html"},
737 { "id": 3, "content-charset": "ISO-8859-1", "content-length": 20, "content-type": "text/html"},
738 { "id": 4, "content-type": "text/plain", "content": "0.5 equals \\u00bd\\n"}
742 # Both the UTF-8 and ISO-8859-1 part should have U+00BD
743 cat_expected_head > EXPECTED.withhtml
744 cat <<EOF >> EXPECTED.withhtml
746 { "id": 2, "content-type": "text/html", "content": "<p>0.5 equals \\u00bd</p>\\n"},
747 { "id": 3, "content-type": "text/html", "content": "<p>0.5 equals \\u00bd</p>\\n"},
748 { "id": 4, "content-type": "text/plain", "content": "0.5 equals \\u00bd\\n"}
752 test_begin_subtest "html parts excluded by default"
753 notmuch show --format=json id:htmlmessage > OUTPUT
754 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.nohtml)"
756 test_begin_subtest "html parts included"
757 notmuch show --format=json --include-html id:htmlmessage > OUTPUT
758 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)"
760 test_begin_subtest "indexes mime-type #1"
761 output=$(notmuch search mimetype:application/unique_identifier | notmuch_search_sanitize)
762 test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
764 test_begin_subtest "indexes mime-type #2"
765 output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize)
766 test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
768 test_begin_subtest "indexes mime-type #3"
769 output=$(notmuch search from:todd and mimetype:multipart/alternative | notmuch_search_sanitize)
770 test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
772 test_begin_subtest "case of Content-Disposition doesn't matter for indexing"
773 cat <<EOF > ${MAIL_DIR}/content-disposition
774 Return-path: <david@tethera.net>
775 Envelope-to: david@tethera.net
776 Delivery-date: Sun, 04 Oct 2015 09:16:03 -0300
777 Received: from gitolite.debian.net ([87.98.215.224])
778 by yantan.tethera.net with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128)
780 (envelope-from <david@tethera.net>)
782 for david@tethera.net; Sun, 04 Oct 2015 09:16:03 -0300
783 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
784 (envelope-from <david@tethera.net>)
785 id 1ZiiC8-0002Rz-Uf; Sun, 04 Oct 2015 12:15:12 +0000
786 Received: (nullmailer pid 28621 invoked by uid 1000); Sun, 04 Oct 2015
788 From: David Bremner <david@tethera.net>
789 To: David Bremner <david@tethera.net>
790 Subject: test attachment
791 User-Agent: Notmuch/0.20.2+93~g33c8777 (http://notmuchmail.org) Emacs/24.5.1
792 (x86_64-pc-linux-gnu)
793 Date: Sun, 04 Oct 2015 09:14:53 -0300
794 Message-ID: <87io6m96f6.fsf@zancas.localnet>
796 Content-Type: multipart/mixed; boundary="=-=-="
799 Content-Type: text/plain
800 Content-Disposition: ATTACHMENT; filename=hello.txt
801 Content-Description: this is a very exciting file
806 Content-Type: text/plain
822 notmuch search --output=tags id:87io6m96f6.fsf@zancas.localnet > OUTPUT
823 test_expect_equal_file EXPECTED OUTPUT