summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-18 12:40:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-18 12:40:43 +0100
commit7bce09dd48c1c493159c10c9694df1437327bd20 (patch)
tree7528f9bf0bcff2cddfb81cb0183997566272efd8 /src
parent4f30ed40b7a25c90ff7ad58d02ef5279cd6efcb7 (diff)
downloadrspamd-7bce09dd48c1c493159c10c9694df1437327bd20.tar.gz
rspamd-7bce09dd48c1c493159c10c9694df1437327bd20.zip
[Fix] Fix legacy history handling in the controller
Issue: #2348
Diffstat (limited to 'src')
-rw-r--r--src/controller.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/controller.c b/src/controller.c
index c786c138e..25774f267 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -1351,7 +1351,7 @@ rspamd_controller_handle_legacy_history (
struct roll_history_row *row, *copied_rows;
guint i, rows_proc, row_num;
struct tm tm;
- gchar timebuf[32];
+ gchar timebuf[32], **syms;
ucl_object_t *top, *obj;
top = ucl_object_typed_new (UCL_ARRAY);
@@ -1405,15 +1405,34 @@ rspamd_controller_handle_legacy_history (
ucl_object_fromdouble (0.0), "required_score", 0, false);
}
- ucl_object_insert_key (obj, ucl_object_fromstring (
- row->symbols), "symbols", 0, false);
- ucl_object_insert_key (obj, ucl_object_fromint (
- row->len), "size", 0, false);
- ucl_object_insert_key (obj, ucl_object_fromdouble (
- row->scan_time), "scan_time", 0, false);
+ syms = g_strsplit_set (row->symbols, ",", -1);
+
+ if (syms) {
+ guint nelts = g_strv_length (syms);
+ ucl_object_t *syms_obj = ucl_object_typed_new (UCL_OBJECT);
+ ucl_object_reserve (syms_obj, nelts);
+
+ for (guint j = 0; j < nelts; j++) {
+ ucl_object_t *cur = ucl_object_typed_new (UCL_OBJECT);
+
+ ucl_object_insert_key (cur, ucl_object_fromdouble (0.0),
+ "score", 0, false);
+ ucl_object_insert_key (syms_obj, cur, syms[j], 0, true);
+ }
+
+ ucl_object_insert_key (obj, syms_obj, "symbols", 0, false);
+ g_strfreev (syms);
+ }
+
+ ucl_object_insert_key (obj, ucl_object_fromint (row->len),
+ "size", 0, false);
+ ucl_object_insert_key (obj,
+ ucl_object_fromdouble (row->scan_time),
+ "scan_time", 0, false);
+
if (row->user[0] != '\0') {
- ucl_object_insert_key (obj, ucl_object_fromstring (
- row->user), "user", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring (row->user),
+ "user", 0, false);
}
if (row->from_addr[0] != '\0') {
ucl_object_insert_key (obj, ucl_object_fromstring (