1 Return-Path: <wking@tremily.us>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 239B0431FC9
\r
6 for <notmuch@notmuchmail.org>; Mon, 3 Feb 2014 02:47:00 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=0 tagged_above=-999 required=5
\r
13 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001]
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id ln8ktshn5u+r for <notmuch@notmuchmail.org>;
\r
18 Mon, 3 Feb 2014 02:46:49 -0800 (PST)
\r
19 Received: from qmta04.westchester.pa.mail.comcast.net
\r
20 (qmta04.westchester.pa.mail.comcast.net [76.96.62.40])
\r
21 by olra.theworths.org (Postfix) with ESMTP id 4EC40431FDB
\r
22 for <notmuch@notmuchmail.org>; Mon, 3 Feb 2014 02:46:49 -0800 (PST)
\r
23 Received: from omta04.westchester.pa.mail.comcast.net ([76.96.62.35])
\r
24 by qmta04.westchester.pa.mail.comcast.net with comcast
\r
25 id Mmlh1n0010ldTLk54mmoVz; Mon, 03 Feb 2014 10:46:48 +0000
\r
26 Received: from odin.tremily.us ([24.18.63.50])
\r
27 by omta04.westchester.pa.mail.comcast.net with comcast
\r
28 id Mmmm1n00L152l3L01mmnZn; Mon, 03 Feb 2014 10:46:48 +0000
\r
29 Received: from mjolnir.tremily.us (unknown [192.168.0.140])
\r
30 by odin.tremily.us (Postfix) with ESMTPS id BE048FB4C6B;
\r
31 Mon, 3 Feb 2014 02:46:45 -0800 (PST)
\r
32 Received: (nullmailer pid 31479 invoked by uid 1000);
\r
33 Mon, 03 Feb 2014 10:45:48 -0000
\r
34 From: "W. Trevor King" <wking@tremily.us>
\r
35 To: notmuch@notmuchmail.org
\r
36 Subject: [PATCH 1/2] notmuch-show: Add content-description output pair
\r
37 Date: Mon, 3 Feb 2014 02:45:33 -0800
\r
39 <4a916b4f80f5cc9b28ddbb9c3eecdabf914d9641.1391423201.git.wking@tremily.us>
\r
40 X-Mailer: git-send-email 1.8.5.2.8.g0f6c0d1
\r
41 In-Reply-To: <cover.1391423201.git.wking@tremily.us>
\r
42 References: <877g9chbay.fsf@qmul.ac.uk>
\r
43 <cover.1391423201.git.wking@tremily.us>
\r
44 In-Reply-To: <cover.1391423201.git.wking@tremily.us>
\r
45 References: <cover.1391423201.git.wking@tremily.us>
\r
47 Content-Type: text/plain; charset=UTF-8
\r
48 Content-Transfer-Encoding: 8bit
\r
49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;
\r
50 s=q20121106; t=1391424408;
\r
51 bh=6cQ+kT34X70UTPaNzC5yeyXhvb2vocR8UUhEtebGZfs=;
\r
52 h=Received:Received:Received:Received:From:To:Subject:Date:
\r
53 Message-Id:MIME-Version:Content-Type;
\r
54 b=Dwo4azb+U3UirA7HukqlGEXyc+7K8W6T9BRICJJhdh83P0M9MzGMiicsNbVX1/QeJ
\r
55 NPq/BTLbNGdG+jcOLDtLYn0txamrld2gvQprWPYtCnj3qaYclW3qhjmF/Am8oOQnoN
\r
56 /ZSK93gtb3cC3YJf0FpbhPZFob5pG27kjcgGSQe5eNrwl73fWb8i464DrPgY7KmcEZ
\r
57 a4phVdPZgFP818naSUkQ2TbpngTmBojPLvb9EwHylfxnitMZ6gOMCXcjlsW2hCcdBX
\r
58 w2GagqA1qKVNm5Y2vLVbWSSBMtGvq4/yGf2ip+pXjkKsNccgYZyzLTdwK2I78ghu7y
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Mon, 03 Feb 2014 10:47:00 -0000
\r
74 Parse and display the Content-Description header [1,2] so UIs
\r
75 rendering message parts have easy access to description strings.
\r
76 Extracting the value is a two-step process (extract [3] and decode
\r
79 [1]: http://tools.ietf.org/html/rfc2045#section-8
\r
80 [2]: http://tools.ietf.org/html/rfc2183#section-3
\r
81 [3]: https://developer.gnome.org/gmime/stable/GMimeObject.html#g-mime-object-get-header
\r
82 [4]: https://developer.gnome.org/gmime/stable/gmime-gmime-utils.html#g-mime-utils-header-decode-text
\r
85 notmuch-show.c | 8 ++++++++
\r
86 test/T160-json.sh | 4 ++--
\r
87 test/T170-sexp.sh | 4 ++--
\r
88 4 files changed, 14 insertions(+), 4 deletions(-)
\r
90 diff --git a/NEWS b/NEWS
\r
91 index 65679eb..0f7b1c8 100644
\r
94 @@ -8,6 +8,8 @@ Command-Line Interface
\r
96 The old format is still available with `--format=sup`.
\r
98 +`notmuch show` now includes envelope Content-Description headers.
\r
100 Notmuch 0.17 (2013-12-30)
\r
101 =========================
\r
103 diff --git a/notmuch-show.c b/notmuch-show.c
\r
104 index d416fbd..a604227 100644
\r
105 --- a/notmuch-show.c
\r
106 +++ b/notmuch-show.c
\r
107 @@ -659,6 +659,9 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
108 GMIME_OBJECT (node->envelope_part) : node->part;
\r
109 GMimeContentType *content_type = g_mime_object_get_content_type (meta);
\r
110 const char *cid = g_mime_object_get_content_id (meta);
\r
111 + const char *encoded_description = g_mime_object_get_header (meta, "content-description");
\r
112 + const char *description = encoded_description ?
\r
113 + g_mime_utils_header_decode_text (encoded_description) : NULL;
\r
114 const char *filename = GMIME_IS_PART (node->part) ?
\r
115 g_mime_part_get_filename (GMIME_PART (node->part)) : NULL;
\r
117 @@ -692,6 +695,11 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
118 sp->string (sp, cid);
\r
121 + if (description) {
\r
122 + sp->map_key (sp, "content-description");
\r
123 + sp->string (sp, description);
\r
127 sp->map_key (sp, "filename");
\r
128 sp->string (sp, filename);
\r
129 diff --git a/test/T160-json.sh b/test/T160-json.sh
\r
130 index c1cf649..53f40ef 100755
\r
131 --- a/test/T160-json.sh
\r
132 +++ b/test/T160-json.sh
\r
133 @@ -41,14 +41,14 @@ id="json-show-inline-attachment-filename@notmuchmail.org"
\r
134 emacs_fcc_message \
\r
136 'This is a test message with inline attachment with a filename' \
\r
137 - "(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")
\r
138 + "(mml-attach-file \"$TEST_DIRECTORY/README\" nil \"Test README\" \"inline\")
\r
140 (insert \"Message-ID: <$id>\n\")"
\r
141 output=$(notmuch show --format=json "id:$id")
\r
142 filename=$(notmuch search --output=files "id:$id")
\r
143 # Get length of README after base64-encoding, minus additional newline.
\r
144 attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 ))
\r
145 -test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"content-length\": $attachment_length, \"content-transfer-encoding\": \"base64\", \"filename\": \"README\"}]}]}, []]]]"
\r
146 +test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"content-description\": \"Test README\", \"content-length\": $attachment_length, \"content-transfer-encoding\": \"base64\", \"filename\": \"README\"}]}]}, []]]]"
\r
148 test_begin_subtest "Search message: json, utf-8"
\r
149 add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""
\r
150 diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh
\r
151 index 667e319..1c087d6 100755
\r
152 --- a/test/T170-sexp.sh
\r
153 +++ b/test/T170-sexp.sh
\r
154 @@ -32,14 +32,14 @@ id="sexp-show-inline-attachment-filename@notmuchmail.org"
\r
155 emacs_fcc_message \
\r
157 'This is a test message with inline attachment with a filename' \
\r
158 - "(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")
\r
159 + "(mml-attach-file \"$TEST_DIRECTORY/README\" nil \"Test README\" \"inline\")
\r
161 (insert \"Message-ID: <$id>\n\")"
\r
162 output=$(notmuch show --format=sexp "id:$id")
\r
163 filename=$(notmuch search --output=files "id:$id")
\r
164 # Get length of README after base64-encoding, minus additional newline.
\r
165 attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 ))
\r
166 -test_expect_equal "$output" "((((:id \"$id\" :match t :excluded nil :filename \"$filename\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\") :headers (:Subject \"sexp-show-inline-attachment-filename\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"test_suite@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\") :body ((:id 1 :content-type \"multipart/mixed\" :content ((:id 2 :content-type \"text/plain\" :content \"This is a test message with inline attachment with a filename\") (:id 3 :content-type \"application/octet-stream\" :filename \"README\" :content-transfer-encoding \"base64\" :content-length $attachment_length))))) ())))"
\r
167 +test_expect_equal "$output" "((((:id \"$id\" :match t :excluded nil :filename \"$filename\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\") :headers (:Subject \"sexp-show-inline-attachment-filename\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"test_suite@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\") :body ((:id 1 :content-type \"multipart/mixed\" :content ((:id 2 :content-type \"text/plain\" :content \"This is a test message with inline attachment with a filename\") (:id 3 :content-type \"application/octet-stream\" :content-description \"Test README\" :filename \"README\" :content-transfer-encoding \"base64\" :content-length $attachment_length))))) ())))"
\r
169 test_begin_subtest "Search message: sexp, utf-8"
\r
170 add_message "[subject]=\"sexp-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""
\r