aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libucl/ucl_emitter_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-02-08 13:32:30 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-02-08 13:46:57 +0000
commit60a221d3e43e1bf2d03b8fd1faec9b3ad78672dc (patch)
treecda2d160728396b0d391ba0112ac621e34d32a16 /contrib/libucl/ucl_emitter_utils.c
parent2f5cc0b94fb8957d9e01390326a06f5bbda15d9a (diff)
downloadrspamd-60a221d3e43e1bf2d03b8fd1faec9b3ad78672dc.tar.gz
rspamd-60a221d3e43e1bf2d03b8fd1faec9b3ad78672dc.zip
[Fix] Strictly filter bad characters when emittin json
Diffstat (limited to 'contrib/libucl/ucl_emitter_utils.c')
-rw-r--r--contrib/libucl/ucl_emitter_utils.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/libucl/ucl_emitter_utils.c b/contrib/libucl/ucl_emitter_utils.c
index 95ac9a5d5..3559eb63d 100644
--- a/contrib/libucl/ucl_emitter_utils.c
+++ b/contrib/libucl/ucl_emitter_utils.c
@@ -102,7 +102,7 @@ ucl_elt_string_write_json (const char *str, size_t size,
func->ucl_emitter_append_character ('"', 1, func->ud);
while (size) {
- if (ucl_test_character (*p, UCL_CHARACTER_JSON_UNSAFE)) {
+ if (ucl_test_character (*p, UCL_CHARACTER_JSON_UNSAFE|UCL_CHARACTER_DENIED)) {
if (len > 0) {
func->ucl_emitter_append_len (c, len, func->ud);
}
@@ -128,6 +128,10 @@ ucl_elt_string_write_json (const char *str, size_t size,
case '"':
func->ucl_emitter_append_len ("\\\"", 2, func->ud);
break;
+ default:
+ /* Emit unicode unknown character */
+ func->ucl_emitter_append_len ("\\uFFFD", 5, func->ud);
+ break;
}
len = 0;
c = ++p;
@@ -138,9 +142,11 @@ ucl_elt_string_write_json (const char *str, size_t size,
}
size --;
}
+
if (len > 0) {
func->ucl_emitter_append_len (c, len, func->ud);
}
+
func->ucl_emitter_append_character ('"', 1, func->ud);
}