[notmuch] [PATCH] Fix invalid JSON output for NULL strings
Michal Sojka
sojkam1 at fel.cvut.cz
Sun Mar 14 13:44:18 PDT 2010
On Sun, 14 Mar 2010 15:01:28 -0400, James Westby <jw+debian at jameswestby.net> wrote:
> On Sun, 14 Mar 2010 19:19:11 +0100, Michal Sojka <sojkam1 at 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?
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 <sojkam1 at fel.cvut.cz>
---
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
More information about the notmuch
mailing list