unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] json_quote_str should handle non-ASCII characters
@ 2010-03-04 10:40 Gregor Hoffleit
  2010-03-04 13:57 ` Sebastian Spaeth
  2010-04-13 15:36 ` Carl Worth
  0 siblings, 2 replies; 12+ messages in thread
From: Gregor Hoffleit @ 2010-03-04 10:40 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-04-23  0:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-04 10:40 [PATCH] json_quote_str should handle non-ASCII characters Gregor Hoffleit
2010-03-04 13:57 ` Sebastian Spaeth
2010-03-04 14:26   ` Gregor Hoffleit
2010-04-13 15:36 ` Carl Worth
2010-04-13 16:37   ` [PATCH] First tests for JSON output and UTF-8 in mail body and subject Gregor Hoffleit
2010-04-15  0:35     ` Carl Worth
2010-04-15  8:33       ` Michal Sojka
2010-04-15 19:58         ` Carl Worth
2010-04-16  8:17           ` Michal Sojka
2010-04-22 21:14             ` Improved diff-based failure reports from the test suite Carl Worth
2010-04-16 11:49       ` [PATCH] First tests for JSON output and UTF-8 in mail body and subject David Edmondson
2010-04-23  0:15       ` Carl Worth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).