1 Return-Path: <amthrax@drake.mit.edu>
\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 6DCE1431FD6
\r
6 for <notmuch@notmuchmail.org>; Tue, 14 Feb 2012 09:34:08 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id Iqn2dsnCLDns for <notmuch@notmuchmail.org>;
\r
16 Tue, 14 Feb 2012 09:34:05 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 372B7431FBF
\r
20 for <notmuch@notmuchmail.org>; Tue, 14 Feb 2012 09:34:00 -0800 (PST)
\r
21 X-AuditID: 12074424-b7fae6d000000906-7c-4f3a9b0703e7
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id D6.57.02310.70B9A3F4; Tue, 14 Feb 2012 12:33:59 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q1EHXxCL019626;
\r
27 Tue, 14 Feb 2012 12:33:59 -0500
\r
28 Received: from drake.mit.edu
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q1EHXvvq016511
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Tue, 14 Feb 2012 12:33:58 -0500 (EST)
\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)
\r
36 (envelope-from <amthrax@drake.mit.edu>)
\r
37 id 1RxMGL-00027H-P0; Tue, 14 Feb 2012 12:33:57 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
41 [PATCH 4/8] show: Unify JSON header output for messages and message parts
\r
42 Date: Tue, 14 Feb 2012 12:33:39 -0500
\r
43 Message-Id: <1329240823-7856-5-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.7.3
\r
45 In-Reply-To: <1329240823-7856-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1329240823-7856-1-git-send-email-amdragon@mit.edu>
\r
48 Content-Type: text/plain; charset=UTF-8
\r
49 Content-Transfer-Encoding: 8bit
\r
50 X-Brightmail-Tracker:
\r
51 H4sIAAAAAAAAA+NgFprOKsWRmVeSWpSXmKPExsUixG6nrss+28rfoP2fosWRPbPYLa5u7We3
\r
52 uH5zJrMDs8fOWXfZPZ6tusXs0fRjMWsAcxSXTUpqTmZZapG+XQJXxseugIIj6RUn3kU3ML6M
\r
53 6GLk5JAQMJGY+PoYG4QtJnHh3nogm4tDSGAfo0T3vu/sEM4GRol9K25AZe4zSdxb3csM4cxn
\r
54 lLj9tIMdpJ9NQENi2/7ljCC2iIC0xM67s1lBbGaBeIkjbevB4sICVRKf5xwDqufgYBFQlWjd
\r
55 KwMS5hWwl2hf9ogZ4gwFiXOrz4GN5BRwkNi/7z/YGCGgmkt3t7JA1AtKnJz5hAVkDLOAusT6
\r
56 eUIQm+QlmrfOZp7AKDQLSdUshKpZSKoWMDKvYpRNya3SzU3MzClOTdYtTk7My0st0jXXy80s
\r
57 0UtNKd3ECA5zF5UdjM2HlA4xCnAwKvHwGlhY+guxJpYVV+YeYpTkYFIS5RWeYeUvxJeUn1KZ
\r
58 kVicEV9UmpNafIhRgoNZSYR303SgHG9KYmVValE+TEqag0VJnFdD652fkEB6YklqdmpqQWoR
\r
59 TFaGg0NJgpdtFlCjYFFqempFWmZOCUKaiYMTZDgP0PAvM0GGFxck5hZnpkPkTzHqcnzvXH+B
\r
60 UYglLz8vVUqc9y1IkQBIUUZpHtwcWHp6xSgO9JYw7y2QKh5gaoOb9ApoCRPQku2nLUCWlCQi
\r
61 pKQaGGsW/hA/Nulxb/vdb8s+OP08W6hQH5fFlzWTObLn1a/N0zaV7VHsColwWcs4UyfLbue0
\r
62 K02v79rFMibnFn/hk34r48n/ffPFay5VQZdm71AqFQubeM139+2HrqnvllxWnXTo57I37xZc
\r
63 Sw6SurnvRqSjWbXsB6sLJW3/7h1gn2V6PHX18lXlWv+VWIozEg21mIuKEwFzQ2D7KgMAAA==
\r
64 X-BeenThere: notmuch@notmuchmail.org
\r
65 X-Mailman-Version: 2.1.13
\r
67 List-Id: "Use and development of the notmuch mail system."
\r
68 <notmuch.notmuchmail.org>
\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
72 List-Post: <mailto:notmuch@notmuchmail.org>
\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
76 X-List-Received-Date: Tue, 14 Feb 2012 17:34:08 -0000
\r
78 This has three ramifications:
\r
79 - Blank To and Cc headers are no longer output for messages.
\r
80 - Dates are now canonicalized for messages, which means they always
\r
81 have a day of the week and GMT is printed +0000 (never -0000)
\r
82 - Invalid From message headers are handled slightly differently, since
\r
83 they get parsed by GMime now instead of notmuch.
\r
85 notmuch-show.c | 35 +++--------------------------------
\r
86 test/crypto | 35 ++++++++++++++---------------------
\r
88 test/json | 6 +++---
\r
89 test/maildir-sync | 2 --
\r
90 test/multipart | 2 +-
\r
91 6 files changed, 23 insertions(+), 61 deletions(-)
\r
93 diff --git a/notmuch-show.c b/notmuch-show.c
\r
94 index 9ca9882..209ff45 100644
\r
95 --- a/notmuch-show.c
\r
96 +++ b/notmuch-show.c
\r
97 @@ -291,36 +291,7 @@ format_headers_message_part_text (GMimeMessage *message)
\r
101 -format_headers_json (const void *ctx, notmuch_message_t *message)
\r
103 - const char *headers[] = {
\r
104 - "Subject", "From", "To", "Cc", "Bcc", "Date"
\r
106 - const char *name, *value;
\r
108 - int first_header = 1;
\r
109 - void *ctx_quote = talloc_new (ctx);
\r
111 - for (i = 0; i < ARRAY_SIZE (headers); i++) {
\r
112 - name = headers[i];
\r
113 - value = notmuch_message_get_header (message, name);
\r
116 - if (!first_header)
\r
117 - fputs (", ", stdout);
\r
118 - first_header = 0;
\r
120 - printf ("%s: %s",
\r
121 - json_quote_str (ctx_quote, name),
\r
122 - json_quote_str (ctx_quote, value));
\r
126 - talloc_free (ctx_quote);
\r
130 -format_headers_message_part_json (GMimeMessage *message)
\r
131 +format_headers_json (GMimeMessage *message)
\r
133 void *ctx = talloc_new (NULL);
\r
134 void *ctx_quote = talloc_new (ctx);
\r
135 @@ -690,7 +661,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
\r
136 format_message_json (ctx, node->envelope_file);
\r
138 printf ("\"headers\": {");
\r
139 - format_headers_json (ctx, node->envelope_file);
\r
140 + format_headers_json (GMIME_MESSAGE (node->part));
\r
143 printf (", \"body\": [");
\r
144 @@ -778,7 +749,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
\r
146 if (GMIME_IS_MESSAGE (node->part)) {
\r
147 printf ("\"headers\": {");
\r
148 - format_headers_message_part_json (GMIME_MESSAGE (node->part));
\r
149 + format_headers_json (GMIME_MESSAGE (node->part));
\r
152 printf (", \"body\": [");
\r
153 diff --git a/test/crypto b/test/crypto
\r
154 index 1dbb60a..7e774c8 100755
\r
157 @@ -50,9 +50,8 @@ expected='[[[{"id": "XXXXX",
\r
158 "headers": {"Subject": "test signed message 001",
\r
159 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
160 "To": "test_suite@notmuchmail.org",
\r
163 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
165 + 01 Jan 2000 12:00:00 +0000"},
\r
167 "sigstatus": [{"status": "good",
\r
168 "fingerprint": "'$FINGERPRINT'",
\r
169 @@ -84,9 +83,8 @@ expected='[[[{"id": "XXXXX",
\r
170 "headers": {"Subject": "test signed message 001",
\r
171 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
172 "To": "test_suite@notmuchmail.org",
\r
175 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
177 + 01 Jan 2000 12:00:00 +0000"},
\r
179 "sigstatus": [{"status": "good",
\r
180 "fingerprint": "'$FINGERPRINT'",
\r
181 @@ -120,9 +118,8 @@ expected='[[[{"id": "XXXXX",
\r
182 "headers": {"Subject": "test signed message 001",
\r
183 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
184 "To": "test_suite@notmuchmail.org",
\r
187 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
189 + 01 Jan 2000 12:00:00 +0000"},
\r
191 "sigstatus": [{"status": "error",
\r
192 "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'",
\r
193 @@ -194,9 +191,8 @@ expected='[[[{"id": "XXXXX",
\r
194 "headers": {"Subject": "test encrypted message 001",
\r
195 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
196 "To": "test_suite@notmuchmail.org",
\r
199 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
201 + 01 Jan 2000 12:00:00 +0000"},
\r
203 "encstatus": [{"status": "good"}],
\r
205 @@ -249,9 +245,8 @@ expected='[[[{"id": "XXXXX",
\r
206 "headers": {"Subject": "test encrypted message 001",
\r
207 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
208 "To": "test_suite@notmuchmail.org",
\r
211 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
213 + 01 Jan 2000 12:00:00 +0000"},
\r
215 "encstatus": [{"status": "bad"}],
\r
216 "content-type": "multipart/encrypted",
\r
217 @@ -284,9 +279,8 @@ expected='[[[{"id": "XXXXX",
\r
218 "headers": {"Subject": "test encrypted message 002",
\r
219 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
220 "To": "test_suite@notmuchmail.org",
\r
223 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
225 + 01 Jan 2000 12:00:00 +0000"},
\r
227 "encstatus": [{"status": "good"}],
\r
228 "sigstatus": [{"status": "good",
\r
229 @@ -339,9 +333,8 @@ expected='[[[{"id": "XXXXX",
\r
230 "headers": {"Subject": "test signed message 001",
\r
231 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
232 "To": "test_suite@notmuchmail.org",
\r
235 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
237 + 01 Jan 2000 12:00:00 +0000"},
\r
239 "sigstatus": [{"status": "error",
\r
240 "keyid": "6D92612D94E46381",
\r
241 diff --git a/test/emacs b/test/emacs
\r
242 index b74cfa9..d4a8d30 100755
\r
245 @@ -78,7 +78,7 @@ thread=$(notmuch search --output=threads subject:message-with-invalid-from)
\r
246 test_emacs "(notmuch-show \"$thread\")
\r
248 cat <<EOF >EXPECTED
\r
249 -Invalid " From <test_suite@notmuchmail.org> (2001-01-05) (inbox)
\r
250 +"Invalid " (2001-01-05) (inbox)
\r
251 Subject: message-with-invalid-from
\r
252 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
253 Date: Fri, 05 Jan 2001 15:43:57 +0000
\r
254 @@ -411,7 +411,7 @@ test_emacs '(notmuch-show "id:\"bought\"")
\r
255 (reverse-region (point-min) (point-max))
\r
257 cat <<EOF >EXPECTED
\r
258 -Sat, 01 Jan 2000 12:00:00 -0000
\r
259 +Sat, 01 Jan 2000 12:00:00 +0000
\r
260 Some One <someone@somewhere.org>
\r
261 Some One Else <notsomeone@somewhere.org>
\r
262 Notmuch <notmuch@notmuchmail.org>
\r
263 diff --git a/test/json b/test/json
\r
264 index 7df4380..1bdffd2 100755
\r
267 @@ -5,7 +5,7 @@ test_description="--format=json output"
\r
268 test_begin_subtest "Show message: json"
\r
269 add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\""
\r
270 output=$(notmuch show --format=json "json-show-message")
\r
271 -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
\r
272 +test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
\r
274 test_begin_subtest "Search message: json"
\r
275 add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""
\r
276 @@ -22,7 +22,7 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\",
\r
277 test_begin_subtest "Show message: json, utf-8"
\r
278 add_message "[subject]=\"json-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\""
\r
279 output=$(notmuch show --format=json "jsön-show-méssage")
\r
280 -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]"
\r
281 +test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]"
\r
283 test_begin_subtest "Show message: json, inline attachment filename"
\r
284 subject='json-show-inline-attachment-filename'
\r
285 @@ -35,7 +35,7 @@ emacs_deliver_message \
\r
286 (insert \"Message-ID: <$id>\n\")"
\r
287 output=$(notmuch show --format=json "id:$id")
\r
288 filename=$(notmuch search --output=files "id:$id")
\r
289 -test_expect_equal "$output" "[[[{\"id\": \"$id\", \"match\": true, \"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\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"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\"}]}]}, []]]]"
\r
290 +test_expect_equal "$output" "[[[{\"id\": \"$id\", \"match\": true, \"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\", \"filename\": \"README\"}]}]}, []]]]"
\r
292 test_begin_subtest "Search message: json, utf-8"
\r
293 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
294 diff --git a/test/maildir-sync b/test/maildir-sync
\r
295 index d5872a5..1ee2db0 100755
\r
296 --- a/test/maildir-sync
\r
297 +++ b/test/maildir-sync
\r
298 @@ -53,8 +53,6 @@ test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",
\r
299 "headers": {"Subject": "Adding replied tag",
\r
300 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
301 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
305 05 Jan 2001 15:43:57 +0000"},
\r
307 diff --git a/test/multipart b/test/multipart
\r
308 index 4d14804..a3036b4 100755
\r
309 --- a/test/multipart
\r
310 +++ b/test/multipart
\r
311 @@ -322,7 +322,7 @@ notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | s
\r
312 echo >>OUTPUT # expect *no* newline at end of output
\r
313 cat <<EOF >EXPECTED
\r
315 -{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "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", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
\r
316 +{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "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": [
\r
317 {"id": 1, "content-type": "multipart/signed", "content": [
\r
318 {"id": 2, "content-type": "multipart/mixed", "content": [
\r
319 {"id": 3, "content-type": "message/rfc822", "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": [
\r