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 5761F4048F0 for ; Sun, 14 Mar 2010 13:44:24 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.211 X-Spam-Level: X-Spam-Status: No, score=-2.211 tagged_above=-999 required=5 tests=[AWL=0.388, 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 DO-WG9r3RnRO for ; Sun, 14 Mar 2010 13:44:23 -0700 (PDT) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id 1EC61454968 for ; Sun, 14 Mar 2010 13:44:23 -0700 (PDT) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id 85A7C19F35CC; Sun, 14 Mar 2010 21:44:22 +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 C3L-6dTk89pH; Sun, 14 Mar 2010 21:44:21 +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 B8AC919F33BD; Sun, 14 Mar 2010 21:44:20 +0100 (CET) Received: from steelpick.localdomain (unknown [213.29.198.144]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id 2A7ABFA003; Sun, 14 Mar 2010 21:44:19 +0100 (CET) Received: from wsh by steelpick.localdomain with local (Exim 4.71) (envelope-from ) id 1Nqufb-00055U-9V; Sun, 14 Mar 2010 21:44:19 +0100 From: Michal Sojka To: James Westby , notmuch@notmuchmail.org, Scott Robinson In-Reply-To: <87ociqbud3.fsf@jameswestby.net> References: <87mxyabwha.fsf@steelpick.localdomain> <1268590751-7478-1-git-send-email-sojkam1@fel.cvut.cz> <87ociqbud3.fsf@jameswestby.net> Date: Sun, 14 Mar 2010 21:44:18 +0100 Message-ID: <87ociqzl99.fsf@steelpick.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [notmuch] [PATCH] Fix invalid JSON output for NULL strings 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 20:44:24 -0000 On Sun, 14 Mar 2010 15:01:28 -0400, James Westby wrote: > On Sun, 14 Mar 2010 19:19:11 +0100, Michal Sojka 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? You're right. When you import messages from mail archive such as http://notmuchmail.org/pipermail/notmuch/, there are no To: headers. This case is already handled by the current code, but what about this more universal solution? It also solves my problem with notmuchsynch. -- >8 -- Signed-off-by: Michal Sojka --- json.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/json.c b/json.c index 9614143..0885d3d 100644 --- a/json.c +++ b/json.c @@ -56,7 +56,7 @@ json_quote_str(const void *ctx, const char *str) int len = 0; if (!str) - return NULL; + return (char*)"null"; for (ptr = str; *ptr; len++, ptr++) { if (*ptr < 32 || *ptr == '\"' || *ptr == '\\') -- 1.7.0