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 5417B431FBC for ; Thu, 4 Mar 2010 02:48:12 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.563 X-Spam-Level: X-Spam-Status: No, score=-0.563 tagged_above=-999 required=5 tests=[AWL=-0.564, BAYES_50=0.001] 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 8jDghtYnl3Mz for ; Thu, 4 Mar 2010 02:48:11 -0800 (PST) X-Greylist: delayed 476 seconds by postgrey-1.32 at olra; Thu, 04 Mar 2010 02:48:11 PST Received: from sam.mediasupervision.de (sam.mediasupervision.de [80.152.3.104]) by olra.theworths.org (Postfix) with ESMTP id 99368431FAE for ; Thu, 4 Mar 2010 02:48:11 -0800 (PST) Received: from localhost (sam.mediasupervision.de [127.0.0.1]) by sam.mediasupervision.de (Postfix) with ESMTP id 3DE13486291 for ; Thu, 4 Mar 2010 11:40:04 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at sam.mediasupervision.de Received: from sam.mediasupervision.de ([127.0.0.1]) by localhost (sam.mediasupervision.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1EgDPjribO5e for ; Thu, 4 Mar 2010 11:40:04 +0100 (CET) Received: by sam.mediasupervision.de (Postfix, from userid 1000) id D5E20486292; Thu, 4 Mar 2010 11:40:03 +0100 (CET) Content-Type: text/plain; charset=UTF-8 From: Gregor Hoffleit To: notmuch Date: Thu, 04 Mar 2010 11:40:03 +0100 Message-Id: <1267697893-sup-4538@sam.mediasupervision.de> User-Agent: Sup/git Content-Transfer-Encoding: 8bit Subject: [notmuch] [PATCH] json_quote_str should handle non-ASCII characters 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: Thu, 04 Mar 2010 10:48:12 -0000 The current code in json_quote_str() only accepts strict printable ASCII code points (i.e. 32-127), all other code points are dropped from the JSON output. This patch accepts code points 32-255. json_quote_str() should handle non-ASCII characters. --- json.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/json.c b/json.c index 9614143..6dc0345 100644 --- a/json.c +++ b/json.c @@ -59,7 +59,7 @@ json_quote_str(const void *ctx, const char *str) return NULL; for (ptr = str; *ptr; len++, ptr++) { - if (*ptr < 32 || *ptr == '\"' || *ptr == '\\') + if ((unsigned char)(*ptr) < 32 || *ptr == '\"' || *ptr == '\\') len++; } @@ -70,7 +70,7 @@ json_quote_str(const void *ctx, const char *str) *ptr2++ = '\"'; while (*ptr) { - if (*ptr > 31 && *ptr != '\"' && *ptr != '\\') { + if ((unsigned char)(*ptr) > 31 && *ptr != '\"' && *ptr != '\\') { *ptr2++ = *ptr++; } else { *ptr2++ = '\\'; -- 1.7.0