Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0DC5A4048F1 for ; Sun, 14 Mar 2010 11:19:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.124 X-Spam-Level: X-Spam-Status: No, score=-2.124 tagged_above=-999 required=5 tests=[AWL=0.475, BAYES_00=-2.599] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n3WeWDRd+L7m for ; Sun, 14 Mar 2010 11:19:17 -0700 (PDT) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id 41A9B454968 for ; Sun, 14 Mar 2010 11:19:17 -0700 (PDT) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id AAB6A19F365D; Sun, 14 Mar 2010 19:19:16 +0100 (CET) X-Virus-Scanned: IMAP AMAVIS Received: from max.feld.cvut.cz ([192.168.200.1]) by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, port 10044) with ESMTP id sOZUIP4Za4ni; Sun, 14 Mar 2010 19:19:15 +0100 (CET) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by max.feld.cvut.cz (Postfix) with ESMTP id 236E519F365F; Sun, 14 Mar 2010 19:19:14 +0100 (CET) Received: from steelpick.localdomain (unknown [213.29.198.144]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id A4057FA004; Sun, 14 Mar 2010 19:19:14 +0100 (CET) Received: from wsh by steelpick.localdomain with local (Exim 4.71) (envelope-from ) id 1NqsPC-0001x5-5J; Sun, 14 Mar 2010 19:19:14 +0100 From: Michal Sojka To: notmuch@notmuchmail.org Date: Sun, 14 Mar 2010 19:19:11 +0100 Message-Id: <1268590751-7478-1-git-send-email-sojkam1@fel.cvut.cz> X-Mailer: git-send-email 1.7.0 In-Reply-To: <87mxyabwha.fsf@steelpick.localdomain> References: <87mxyabwha.fsf@steelpick.localdomain> Subject: [notmuch] [PATCH] Produce valid JSON output even if mail body is empty X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2010 18:19:18 -0000 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 --- notmuch-show.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) 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); -- 1.7.0