From d8ccf48b06bf47a4ed53bafd9f653c6c3c0e80a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Tue, 4 Jan 2011 21:12:54 +0100 Subject: [PATCH] json encoder: Correctly encode \t and \r. Ticket #163 --- src/htsmsg_json.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/htsmsg_json.c b/src/htsmsg_json.c index 0517de1c..88cd0e31 100644 --- a/src/htsmsg_json.c +++ b/src/htsmsg_json.c @@ -37,13 +37,17 @@ htsmsg_json_encode_string(const char *str, htsbuf_queue_t *hq) htsbuf_append(hq, "\"", 1); while(*s != 0) { - if(*s == '"' || *s == '\\' || *s == '\n') { + if(*s == '"' || *s == '\\' || *s == '\n' || *s == '\t' || *s == '\r') { htsbuf_append(hq, str, s - str); if(*s == '"') htsbuf_append(hq, "\\\"", 2); else if(*s == '\n') htsbuf_append(hq, "\\n", 2); + else if(*s == '\t') + htsbuf_append(hq, "\\t", 2); + else if(*s == '\r') + htsbuf_append(hq, "\\r", 2); else htsbuf_append(hq, "\\\\", 2); s++;