diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-02 19:04:02 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-02 19:04:02 +0000 |
commit | 4a455a7b342a19bf45adc4fabc1b156fe7107c09 (patch) | |
tree | 097899cbbcf3c7f8a14fca554504de6f81d5fdcc /src | |
parent | cd17349670f89fced7e3384ed32ae82f01c7616c (diff) | |
download | rspamd-4a455a7b342a19bf45adc4fabc1b156fe7107c09.tar.gz rspamd-4a455a7b342a19bf45adc4fabc1b156fe7107c09.zip |
Allow NULL path to add top level documentation strings
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/cfg_rcl.c | 53 | ||||
-rw-r--r-- | src/plugins/surbl.c | 3 |
2 files changed, 35 insertions, 21 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index a493e9c32..ff349e75e 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -3077,33 +3077,44 @@ rspamd_rcl_add_doc_by_path (struct rspamd_config *cfg, ucl_object_t *obj; gchar **path_components, **comp; - found = ucl_lookup_path (cfg->doc_strings, doc_path); - - if (found != NULL) { - return rspamd_rcl_add_doc_obj ((ucl_object_t *)found, + if (doc_path == NULL) { + /* Assume top object */ + return rspamd_rcl_add_doc_obj (cfg->doc_strings, doc_string, doc_name, type, handler, flags); } + else { + found = ucl_lookup_path (cfg->doc_strings, doc_path); - /* Otherwise we need to insert all components of the path */ - path_components = g_strsplit_set (doc_path, ".", -1); - cur = cfg->doc_strings; - - for (comp = path_components; *comp != NULL; comp ++) { - if (ucl_object_type (cur) != UCL_OBJECT) { - msg_err_config ("Bad path while lookup for '%s' at %s", - doc_path, *comp); - return NULL; + if (found != NULL) { + return rspamd_rcl_add_doc_obj ((ucl_object_t *) found, + doc_string, doc_name, type, handler, flags); } - found = ucl_object_find_key (cur, *comp); + /* Otherwise we need to insert all components of the path */ + path_components = g_strsplit_set (doc_path, ".", -1); + cur = cfg->doc_strings; - if (found == NULL) { - obj = ucl_object_typed_new (UCL_OBJECT); - ucl_object_insert_key ((ucl_object_t *)cur, obj, *comp, 0, true); - cur = obj; - } - else { - cur = found; + for (comp = path_components; *comp != NULL; comp++) { + if (ucl_object_type (cur) != UCL_OBJECT) { + msg_err_config ("Bad path while lookup for '%s' at %s", + doc_path, *comp); + return NULL; + } + + found = ucl_object_find_key (cur, *comp); + + if (found == NULL) { + obj = ucl_object_typed_new (UCL_OBJECT); + ucl_object_insert_key ((ucl_object_t *) cur, + obj, + *comp, + 0, + true); + cur = obj; + } + else { + cur = found; + } } } diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index b83aad138..baa125422 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -292,6 +292,9 @@ surbl_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) *ctx = (struct module_ctx *)surbl_module_ctx; + rspamd_rcl_add_doc_by_path (cfg, NULL, + "URL blacklist plugin", + "surbl", UCL_OBJECT, NULL, 0); rspamd_rcl_add_doc_by_path (cfg, "surbl", "List of redirector servers", "redirector", UCL_STRING, NULL, 0); |