aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-09-02 16:35:31 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-09-02 16:35:31 +0100
commit1b60ee74a01892bdec4424138dd80958c921f3cc (patch)
treeb0818aa52dda2560d9185516070d5adea709eb9f /src/lua
parent48e40eda8508e0452397e08ce31f11d9e611e8bf (diff)
downloadrspamd-1b60ee74a01892bdec4424138dd80958c921f3cc.tar.gz
rspamd-1b60ee74a01892bdec4424138dd80958c921f3cc.zip
[Minor] Forgot to handle `parent`
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_config.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 754df856c..be4dd7081 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1969,7 +1969,7 @@ lua_config_register_symbol_from_table(lua_State *L, struct rspamd_config *cfg,
double weight = 1.0, score = NAN;
const char *type_str, *group = NULL, *description = NULL;
GArray *allowed_ids = NULL, *forbidden_ids = NULL;
- int id, nshots, cb_ref;
+ int id, nshots, cb_ref, parent = -1;
unsigned int flags = 0;
gboolean optional = FALSE;
@@ -2047,10 +2047,34 @@ lua_config_register_symbol_from_table(lua_State *L, struct rspamd_config *cfg,
if (lua_type(L, -1) == LUA_TSTRING) {
type_str = lua_tostring(L, -1);
- type = lua_parse_symbol_type(type_str);
+ }
+ else {
+ type_str = "normal";
}
lua_pop(L, 1);
+ type = lua_parse_symbol_type(type_str);
+
+ if (!name && !(type & SYMBOL_TYPE_CALLBACK)) {
+ luaL_error(L, "no symbol name but type is not callback");
+
+ return false;
+ }
+ else if (!(type & SYMBOL_TYPE_VIRTUAL) && cb_ref == -1) {
+ luaL_error(L, "no callback for symbol %s", name);
+
+ return false;
+ }
+
+ lua_pushstring(L, "parent");
+ lua_gettable(L, -2);
+
+ if (lua_type(L, -1) == LUA_TNUMBER) {
+ parent = lua_tointeger(L, -1);
+ }
+ lua_pop(L, 1);
+
+
/* Deal with flags and ids */
lua_pushstring(L, "flags");
lua_gettable(L, -2);
@@ -2101,7 +2125,7 @@ lua_config_register_symbol_from_table(lua_State *L, struct rspamd_config *cfg,
weight,
priority,
type | flags,
- -1,
+ parent,
allowed_ids, forbidden_ids,
optional);