From a0c262d08b46652ef2a256050ad66f65a8f95a93 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 27 Jun 2012 23:50:01 -0400 Subject: [PATCH] Escaping the slash when dump --- src/dump.c | 5 +++-- test/suites/valid/string-escapes/output | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dump.c b/src/dump.c index e39197a..7ff5708 100644 --- a/src/dump.c +++ b/src/dump.c @@ -84,7 +84,7 @@ static int dump_string(const char *str, int ascii, json_dump_callback_t dump, vo return -1; /* mandatory escape or control char */ - if(codepoint == '\\' || codepoint == '"' || codepoint < 0x20) + if(codepoint == '\\' || codepoint == '/' || codepoint == '"' || codepoint < 0x20) break; /* non-ASCII */ @@ -102,11 +102,12 @@ static int dump_string(const char *str, int ascii, json_dump_callback_t dump, vo if(end == pos) break; - /* handle \, ", and control codes */ + /* handle \, /, ", and control codes */ length = 2; switch(codepoint) { case '\\': text = "\\\\"; break; + case '/': text = "\\/"; break; case '\"': text = "\\\""; break; case '\b': text = "\\b"; break; case '\f': text = "\\f"; break; diff --git a/test/suites/valid/string-escapes/output b/test/suites/valid/string-escapes/output index ca5c1c6..7f49553 100644 --- a/test/suites/valid/string-escapes/output +++ b/test/suites/valid/string-escapes/output @@ -1 +1 @@ -["\"\\/\b\f\n\r\t"] \ No newline at end of file +["\"\\\/\b\f\n\r\t"] \ No newline at end of file -- 2.1.4