| Submitter | Michal Sojka |
|---|---|
| Date | 2010-03-14 18:19:11 |
| Message ID | <1268590751-7478-1-git-send-email-sojkam1@fel.cvut.cz> |
| Download | mbox | patch |
| Permalink | /patch/429/ |
| State | New |
| Headers | show |
Comments
On Sun, 14 Mar 2010 19:19:11 +0100, Michal Sojka <sojkam1@fel.cvut.cz> wrote: > Mails with empty body produced the following output: > "body": [{"id": 1, "content-type": "text/plain", "content": (null)}] > The (null) is not valid JSON syntax. Is this just something that can happen with the body? I've see (null) in the emacs interface when I've done something silly such as opening a newer notmuch db with an old client. Should all the attributes be guarded in a similar manner to ensure valid JSON? Thanks, James
Patch
diff --git a/notmuch-show.c b/notmuch-show.c index ff1fecb..cc2fb6a 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -323,7 +323,7 @@ format_part_json (GMimeObject *part, int *part_count) show_part_content (part, stream_memory); part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (stream_memory)); - printf (", \"content\": %s", json_quote_str (ctx, (char *) part_content->data)); + printf (", \"content\": %s", json_quote_str (ctx, part_content->data ? (char *)part_content->data : "")); } fputs ("}", stdout);
Mails with empty body produced the following output: "body": [{"id": 1, "content-type": "text/plain", "content": (null)}] The (null) is not valid JSON syntax. This patch changes the output to: "body": [{"id": 1, "content-type": "text/plain", "content": ""}] Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz> --- notmuch-show.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)