From: Vsevolod Stakhov Date: Sat, 30 Nov 2013 00:21:04 +0000 (+0000) Subject: Fix fuzzy check configuration. X-Git-Tag: 0.6.0~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7e08afed0e793c5d3f0db161a1f5a8931c1f3143;p=rspamd.git Fix fuzzy check configuration. --- diff --git a/conf/options.conf b/conf/options.conf index b074c5556..841372ec2 100644 --- a/conf/options.conf +++ b/conf/options.conf @@ -2,7 +2,7 @@ options { pidfile = "$RUNDIR/rspamd.pid"; - filters = "chartable,dkim,spf,surbl,regexp"; + filters = "chartable,dkim,spf,surbl,regexp,fuzzy_check"; raw_mode = false; one_shot = false; dns_timeout = 1s; diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index de3fdb57b..71be7116e 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -190,15 +190,19 @@ parse_flags_string (struct config_file *cfg, ucl_object_t *val) { ucl_object_t *elt; struct fuzzy_mapping *map; + const gchar *sym = NULL; if (val->type == UCL_STRING) { parse_flags_string_old (cfg, ucl_obj_tostring (val)); } else if (val->type == UCL_OBJECT) { elt = ucl_obj_get_key (val, "symbol"); - if (elt != NULL) { + if (elt == NULL || !ucl_object_tostring_safe (elt, &sym)) { + sym = ucl_object_key (val); + } + if (sym != NULL) { map = memory_pool_alloc (fuzzy_module_ctx->fuzzy_pool, sizeof (struct fuzzy_mapping)); - map->symbol = ucl_obj_tostring (elt); + map->symbol = sym; elt = ucl_obj_get_key (val, "flag"); if (elt != NULL && ucl_obj_toint_safe (elt, &map->fuzzy_flag)) { elt = ucl_obj_get_key (val, "weight"); @@ -365,6 +369,7 @@ gint fuzzy_check_module_config (struct config_file *cfg) { ucl_object_t *value, *cur; + ucl_object_iter_t it = NULL; gint res = TRUE; if ((value = get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) { @@ -434,7 +439,7 @@ fuzzy_check_module_config (struct config_file *cfg) } } if ((value = get_module_opt (cfg, "fuzzy_check", "fuzzy_map")) != NULL) { - LL_FOREACH (value, cur) { + while ((cur = ucl_iterate_object (value, &it, true)) != NULL) { parse_flags_string (cfg, cur); } }