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 A9C91431FAF
\r
6 for <notmuch@notmuchmail.org>; Sun, 19 Feb 2012 16:26:46 -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 NrhqZWEpbVuw for <notmuch@notmuchmail.org>;
\r
16 Sun, 19 Feb 2012 16:26:42 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id E51B8431FC9
\r
20 for <notmuch@notmuchmail.org>; Sun, 19 Feb 2012 16:26:36 -0800 (PST)
\r
21 X-AuditID: 12074422-b7fd66d0000008f9-c4-4f41933cae99
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 90.06.02297.C33914F4; Sun, 19 Feb 2012 19:26:36 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q1K0QakW024839;
\r
27 Sun, 19 Feb 2012 19:26:36 -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 q1K0QYbI000309
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sun, 19 Feb 2012 19:26:35 -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 1RzH5N-0001yL-Lt; Sun, 19 Feb 2012 19:26:33 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
41 [PATCH v2 4/8] show: Unify JSON header output for messages and message parts
\r
42 Date: Sun, 19 Feb 2012 19:26:26 -0500
\r
43 Message-Id: <1329697590-7404-5-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.7.3
\r
45 In-Reply-To: <1329697590-7404-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1329240823-7856-1-git-send-email-amdragon@mit.edu>
\r
47 <1329697590-7404-1-git-send-email-amdragon@mit.edu>
\r
49 Content-Type: text/plain; charset=UTF-8
\r
50 Content-Transfer-Encoding: 8bit
\r
51 X-Brightmail-Tracker:
\r
52 H4sIAAAAAAAAA+NgFuphleLIzCtJLcpLzFFi42IR4hTV1rWZ7OhvsKJD1+L6zZnMFm9WzmN1
\r
53 YPI4/HUhi8ezVbeYA5iiuGxSUnMyy1KL9O0SuDI+dgUUHEmvOPEuuoHxZUQXIyeHhICJxNOr
\r
54 s1ggbDGJC/fWs3UxcnEICexjlHi4/gArhLOBUeJX9y0mCOc+k8TiPUtZIJz5jBK/f35gBeln
\r
55 E9CQ2LZ/OSOILSIgLbHz7mywOLOAlcThq5vAbGGBeon/azcA1XBwsAioSpxcYQgS5hWwl3j0
\r
56 5yMTxBkKEudWn2MHKeEUcJBYvcMVJCwkUCpx5MkWJohyQYmTM5+wgJQwC6hLrJ8nBLFIXqJ5
\r
57 62zmCYxCs5BUzUKomoWkagEj8ypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdU73czBK91JTSTYyg
\r
58 gGZ3UdrB+POg0iFGAQ5GJR5eyTIHfyHWxLLiytxDjJIcTEqivKcmOPoL8SXlp1RmJBZnxBeV
\r
59 5qQWH2KU4GBWEuFdYA+U401JrKxKLcqHSUlzsCiJ86prvfMTEkhPLEnNTk0tSC2CycpwcChJ
\r
60 8O6aBNQoWJSanlqRlplTgpBm4uAEGc4DNPwaSA1vcUFibnFmOkT+FKMux4FPzy8wCrHk5eel
\r
61 Sonz7gcpEgApyijNg5sDS0SvGMWB3hLmTQOp4gEmMbhJr4CWMAEt4RWyA1lSkoiQkmpgVE7e
\r
62 5z5hX19j49kYzddTuT9mb3jYd6lg2w+76PYQ2XrVXzNPfU9sdUmpfBeus7niptfvhZqdiip2
\r
63 +7S2/5JkUGCdmnLp8mn2Dbks13Na/jOlzF2le4v/faDKquJd12bu7+wUclX6KvEgNvSBdser
\r
64 g/stjpoGpM64Munt1fvMuS8v/4lmSzohqMRSnJFoqMVcVJwIANSSrb4fAwAA
\r
65 Cc: tomi.ollila@iki.fi
\r
66 X-BeenThere: notmuch@notmuchmail.org
\r
67 X-Mailman-Version: 2.1.13
\r
69 List-Id: "Use and development of the notmuch mail system."
\r
70 <notmuch.notmuchmail.org>
\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
74 List-Post: <mailto:notmuch@notmuchmail.org>
\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
77 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
78 X-List-Received-Date: Mon, 20 Feb 2012 00:26:47 -0000
\r
80 This has three ramifications:
\r
81 - Blank To and Cc headers are no longer output for messages.
\r
82 - Dates are now canonicalized for messages, which means they always
\r
83 have a day of the week and GMT is printed +0000 (never -0000)
\r
84 - Invalid From message headers are handled slightly differently, since
\r
85 they get parsed by GMime now instead of notmuch.
\r
87 notmuch-show.c | 35 +++--------------------------------
\r
88 test/crypto | 35 ++++++++++++++---------------------
\r
90 test/json | 6 +++---
\r
91 test/maildir-sync | 2 --
\r
92 test/multipart | 2 +-
\r
93 6 files changed, 23 insertions(+), 61 deletions(-)
\r
95 diff --git a/notmuch-show.c b/notmuch-show.c
\r
96 index 9ca9882..209ff45 100644
\r
97 --- a/notmuch-show.c
\r
98 +++ b/notmuch-show.c
\r
99 @@ -291,36 +291,7 @@ format_headers_message_part_text (GMimeMessage *message)
\r
103 -format_headers_json (const void *ctx, notmuch_message_t *message)
\r
105 - const char *headers[] = {
\r
106 - "Subject", "From", "To", "Cc", "Bcc", "Date"
\r
108 - const char *name, *value;
\r
110 - int first_header = 1;
\r
111 - void *ctx_quote = talloc_new (ctx);
\r
113 - for (i = 0; i < ARRAY_SIZE (headers); i++) {
\r
114 - name = headers[i];
\r
115 - value = notmuch_message_get_header (message, name);
\r
118 - if (!first_header)
\r
119 - fputs (", ", stdout);
\r
120 - first_header = 0;
\r
122 - printf ("%s: %s",
\r
123 - json_quote_str (ctx_quote, name),
\r
124 - json_quote_str (ctx_quote, value));
\r
128 - talloc_free (ctx_quote);
\r
132 -format_headers_message_part_json (GMimeMessage *message)
\r
133 +format_headers_json (GMimeMessage *message)
\r
135 void *ctx = talloc_new (NULL);
\r
136 void *ctx_quote = talloc_new (ctx);
\r
137 @@ -690,7 +661,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
\r
138 format_message_json (ctx, node->envelope_file);
\r
140 printf ("\"headers\": {");
\r
141 - format_headers_json (ctx, node->envelope_file);
\r
142 + format_headers_json (GMIME_MESSAGE (node->part));
\r
145 printf (", \"body\": [");
\r
146 @@ -778,7 +749,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
\r
148 if (GMIME_IS_MESSAGE (node->part)) {
\r
149 printf ("\"headers\": {");
\r
150 - format_headers_message_part_json (GMIME_MESSAGE (node->part));
\r
151 + format_headers_json (GMIME_MESSAGE (node->part));
\r
154 printf (", \"body\": [");
\r
155 diff --git a/test/crypto b/test/crypto
\r
156 index 1dbb60a..7e774c8 100755
\r
159 @@ -50,9 +50,8 @@ expected='[[[{"id": "XXXXX",
\r
160 "headers": {"Subject": "test signed message 001",
\r
161 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
162 "To": "test_suite@notmuchmail.org",
\r
165 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
167 + 01 Jan 2000 12:00:00 +0000"},
\r
169 "sigstatus": [{"status": "good",
\r
170 "fingerprint": "'$FINGERPRINT'",
\r
171 @@ -84,9 +83,8 @@ expected='[[[{"id": "XXXXX",
\r
172 "headers": {"Subject": "test signed message 001",
\r
173 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
174 "To": "test_suite@notmuchmail.org",
\r
177 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
179 + 01 Jan 2000 12:00:00 +0000"},
\r
181 "sigstatus": [{"status": "good",
\r
182 "fingerprint": "'$FINGERPRINT'",
\r
183 @@ -120,9 +118,8 @@ expected='[[[{"id": "XXXXX",
\r
184 "headers": {"Subject": "test signed message 001",
\r
185 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
186 "To": "test_suite@notmuchmail.org",
\r
189 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
191 + 01 Jan 2000 12:00:00 +0000"},
\r
193 "sigstatus": [{"status": "error",
\r
194 "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'",
\r
195 @@ -194,9 +191,8 @@ expected='[[[{"id": "XXXXX",
\r
196 "headers": {"Subject": "test encrypted message 001",
\r
197 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
198 "To": "test_suite@notmuchmail.org",
\r
201 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
203 + 01 Jan 2000 12:00:00 +0000"},
\r
205 "encstatus": [{"status": "good"}],
\r
207 @@ -249,9 +245,8 @@ expected='[[[{"id": "XXXXX",
\r
208 "headers": {"Subject": "test encrypted message 001",
\r
209 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
210 "To": "test_suite@notmuchmail.org",
\r
213 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
215 + 01 Jan 2000 12:00:00 +0000"},
\r
217 "encstatus": [{"status": "bad"}],
\r
218 "content-type": "multipart/encrypted",
\r
219 @@ -284,9 +279,8 @@ expected='[[[{"id": "XXXXX",
\r
220 "headers": {"Subject": "test encrypted message 002",
\r
221 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
222 "To": "test_suite@notmuchmail.org",
\r
225 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
227 + 01 Jan 2000 12:00:00 +0000"},
\r
229 "encstatus": [{"status": "good"}],
\r
230 "sigstatus": [{"status": "good",
\r
231 @@ -339,9 +333,8 @@ expected='[[[{"id": "XXXXX",
\r
232 "headers": {"Subject": "test signed message 001",
\r
233 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
234 "To": "test_suite@notmuchmail.org",
\r
237 - "Date": "01 Jan 2000 12:00:00 -0000"},
\r
239 + 01 Jan 2000 12:00:00 +0000"},
\r
241 "sigstatus": [{"status": "error",
\r
242 "keyid": "6D92612D94E46381",
\r
243 diff --git a/test/emacs b/test/emacs
\r
244 index b74cfa9..d4a8d30 100755
\r
247 @@ -78,7 +78,7 @@ thread=$(notmuch search --output=threads subject:message-with-invalid-from)
\r
248 test_emacs "(notmuch-show \"$thread\")
\r
250 cat <<EOF >EXPECTED
\r
251 -Invalid " From <test_suite@notmuchmail.org> (2001-01-05) (inbox)
\r
252 +"Invalid " (2001-01-05) (inbox)
\r
253 Subject: message-with-invalid-from
\r
254 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
255 Date: Fri, 05 Jan 2001 15:43:57 +0000
\r
256 @@ -411,7 +411,7 @@ test_emacs '(notmuch-show "id:\"bought\"")
\r
257 (reverse-region (point-min) (point-max))
\r
259 cat <<EOF >EXPECTED
\r
260 -Sat, 01 Jan 2000 12:00:00 -0000
\r
261 +Sat, 01 Jan 2000 12:00:00 +0000
\r
262 Some One <someone@somewhere.org>
\r
263 Some One Else <notsomeone@somewhere.org>
\r
264 Notmuch <notmuch@notmuchmail.org>
\r
265 diff --git a/test/json b/test/json
\r
266 index 7df4380..1bdffd2 100755
\r
269 @@ -5,7 +5,7 @@ test_description="--format=json output"
\r
270 test_begin_subtest "Show message: json"
\r
271 add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\""
\r
272 output=$(notmuch show --format=json "json-show-message")
\r
273 -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
274 +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
276 test_begin_subtest "Search message: json"
\r
277 add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""
\r
278 @@ -22,7 +22,7 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\",
\r
279 test_begin_subtest "Show message: json, utf-8"
\r
280 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
281 output=$(notmuch show --format=json "jsön-show-méssage")
\r
282 -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
283 +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
285 test_begin_subtest "Show message: json, inline attachment filename"
\r
286 subject='json-show-inline-attachment-filename'
\r
287 @@ -35,7 +35,7 @@ emacs_deliver_message \
\r
288 (insert \"Message-ID: <$id>\n\")"
\r
289 output=$(notmuch show --format=json "id:$id")
\r
290 filename=$(notmuch search --output=files "id:$id")
\r
291 -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
292 +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
294 test_begin_subtest "Search message: json, utf-8"
\r
295 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
296 diff --git a/test/maildir-sync b/test/maildir-sync
\r
297 index d5872a5..1ee2db0 100755
\r
298 --- a/test/maildir-sync
\r
299 +++ b/test/maildir-sync
\r
300 @@ -53,8 +53,6 @@ test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",
\r
301 "headers": {"Subject": "Adding replied tag",
\r
302 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
303 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
307 05 Jan 2001 15:43:57 +0000"},
\r
309 diff --git a/test/multipart b/test/multipart
\r
310 index 4d14804..a3036b4 100755
\r
311 --- a/test/multipart
\r
312 +++ b/test/multipart
\r
313 @@ -322,7 +322,7 @@ notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | s
\r
314 echo >>OUTPUT # expect *no* newline at end of output
\r
315 cat <<EOF >EXPECTED
\r
317 -{"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
318 +{"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
319 {"id": 1, "content-type": "multipart/signed", "content": [
\r
320 {"id": 2, "content-type": "multipart/mixed", "content": [
\r
321 {"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