diff options
author | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:33 +0000 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:33 +0000 |
commit | 6aaf5ba7ed0980c14bdc554fc8839a2126455ed5 (patch) | |
tree | 6161925716661486e7f47c479668a9487b039d83 /src/common.c | |
parent | New upstream version 1.7.0+dfsg (diff) | |
download | netdata-6aaf5ba7ed0980c14bdc554fc8839a2126455ed5.tar.xz netdata-6aaf5ba7ed0980c14bdc554fc8839a2126455ed5.zip |
New upstream version 1.8.0+dfsgupstream/1.8.0+dfsg
Diffstat (limited to '')
-rw-r--r-- | src/common.c | 15 |
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++; } } |