summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/common.c b/src/common.c
index aa75c198d..5a953672d 100644
--- a/src/common.c
+++ b/src/common.c
@@ -227,9 +227,18 @@ void json_escape_string(char *dst, const char *src, size_t size) {
}
void json_fix_string(char *s) {
- for( ; *s ;s++) {
- if(unlikely(*s == '\\')) *s = '/';
- else if(unlikely(*s == '"')) *s = '\'';
+ unsigned char c;
+ while((c = (unsigned char)*s)) {
+ if(unlikely(c == '\\'))
+ *s++ = '/';
+ else if(unlikely(c == '"'))
+ *s++ = '\'';
+ else if(unlikely(isspace(c) || iscntrl(c)))
+ *s++ = ' ';
+ else if(unlikely(!isprint(c) || c > 127))
+ *s++ = '_';
+ else
+ s++;
}
}