Escaping the slash when dump

This commit is contained in:
Juan Basso 2012-06-27 23:50:01 -04:00
parent f62b1f5d69
commit a0c262d08b
2 changed files with 4 additions and 3 deletions

View File

@ -84,7 +84,7 @@ static int dump_string(const char *str, int ascii, json_dump_callback_t dump, vo
return -1; return -1;
/* mandatory escape or control char */ /* mandatory escape or control char */
if(codepoint == '\\' || codepoint == '"' || codepoint < 0x20) if(codepoint == '\\' || codepoint == '/' || codepoint == '"' || codepoint < 0x20)
break; break;
/* non-ASCII */ /* non-ASCII */
@ -102,11 +102,12 @@ static int dump_string(const char *str, int ascii, json_dump_callback_t dump, vo
if(end == pos) if(end == pos)
break; break;
/* handle \, ", and control codes */ /* handle \, /, ", and control codes */
length = 2; length = 2;
switch(codepoint) switch(codepoint)
{ {
case '\\': text = "\\\\"; break; case '\\': text = "\\\\"; break;
case '/': text = "\\/"; break;
case '\"': text = "\\\""; break; case '\"': text = "\\\""; break;
case '\b': text = "\\b"; break; case '\b': text = "\\b"; break;
case '\f': text = "\\f"; break; case '\f': text = "\\f"; break;

View File

@ -1 +1 @@
["\"\\/\b\f\n\r\t"] ["\"\\\/\b\f\n\r\t"]