From 418b59eb3b01a3729146e3d48c96a5687baed2c9 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 15 Nov 2013 14:55:40 +0000 Subject: [PATCH] Fix options in statfiles. --- src/cfg_file.h | 2 +- src/cfg_rcl.c | 2 ++ src/cfg_utils.c | 4 ---- src/cfg_xml.c | 3 ++- src/lua/lua_classifier.c | 7 ++++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cfg_file.h b/src/cfg_file.h index b4cc4ded1..f2744cb2c 100644 --- a/src/cfg_file.h +++ b/src/cfg_file.h @@ -217,7 +217,7 @@ struct statfile { statfile_normalize_func normalizer; /**< function that is used as normaliser */ void *normalizer_data; /**< normalizer function params */ gchar *normalizer_str; /**< source string (for dump) */ - GHashTable *opts; /**< different statfile options */ + ucl_object_t *opts; /**< other options */ gboolean is_spam; /**< spam flag */ }; diff --git a/src/cfg_rcl.c b/src/cfg_rcl.c index 956c60bb8..be7bb2a48 100644 --- a/src/cfg_rcl.c +++ b/src/cfg_rcl.c @@ -772,6 +772,8 @@ rspamd_rcl_statfile_handler (struct config_file *cfg, ucl_object_t *obj, return FALSE; } + st->opts = obj; + return TRUE; } diff --git a/src/cfg_utils.c b/src/cfg_utils.c index 711c045ab..42672e9f7 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -802,10 +802,6 @@ check_statfile_conf (struct config_file *cfg, struct statfile *c) if (c == NULL) { c = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile)); } - if (c->opts == NULL) { - c->opts = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); - memory_pool_add_destructor (cfg->cfg_pool, (pool_destruct_func) g_hash_table_destroy, c->opts); - } return c; } diff --git a/src/cfg_xml.c b/src/cfg_xml.c index c183e6209..ffe9b8027 100644 --- a/src/cfg_xml.c +++ b/src/cfg_xml.c @@ -910,7 +910,8 @@ rspamd_xml_text (GMarkupParseContext *context, const gchar *text, gsize text_len top = ud->parent_pointer[ud->nested - 1]; ud->parent_pointer[ud->nested - 1] = - ucl_object_insert_key (top, ucl_object_fromstring_common (text, text_len, UCL_STRING_PARSE), + ucl_object_insert_key (top, ucl_object_fromstring_common (text, text_len, + UCL_STRING_PARSE|UCL_STRING_PARSE_BYTES), ud->section_name[ud->nested], 0, true); } diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c index 33e7ea9f2..be574319a 100644 --- a/src/lua/lua_classifier.c +++ b/src/lua/lua_classifier.c @@ -381,14 +381,15 @@ static gint lua_statfile_get_param (lua_State *L) { struct statfile *st = lua_check_statfile (L); - const gchar *param, *value; + const gchar *param; + ucl_object_t *value; param = luaL_checkstring (L, 2); if (st != NULL && param != NULL) { - value = g_hash_table_lookup (st->opts, param); + value = ucl_object_find_key (st->opts, param); if (value != NULL) { - lua_pushstring (L, value); + lua_pushstring (L, ucl_object_tostring_forced (value)); return 1; } } -- 2.39.5