aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-23 16:32:34 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-23 16:32:34 +0000
commit012b099a308711da7982c8dfe39dd89c55e1de14 (patch)
tree065696adf4f6be1c8443d9ddd27117a8e9a7223c /src/plugins/regexp.c
parent4b11f51f8e13ec8b77041c37279079d057a5e864 (diff)
downloadrspamd-012b099a308711da7982c8dfe39dd89c55e1de14.tar.gz
rspamd-012b099a308711da7982c8dfe39dd89c55e1de14.zip
Improve mime expressions processing.
Diffstat (limited to 'src/plugins/regexp.c')
-rw-r--r--src/plugins/regexp.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 53049656a..159399dfd 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -138,11 +138,13 @@ regexp_module_config (struct rspamd_config *cfg)
ucl_obj_tostring (value), cfg->raw_mode)) {
res = FALSE;
}
- register_symbol (&cfg->cache,
- cur_item->symbol,
- 1,
- process_regexp_item,
- cur_item);
+ else {
+ register_symbol (&cfg->cache,
+ cur_item->symbol,
+ 1,
+ process_regexp_item,
+ cur_item);
+ }
}
else if (value->type == UCL_USERDATA) {
cur_item = rspamd_mempool_alloc0 (regexp_module_ctx->regexp_pool,
@@ -176,7 +178,7 @@ regexp_module_reconfig (struct rspamd_config *cfg)
static gboolean rspamd_lua_call_expression_func(
struct ucl_lua_funcdata *lua_data, struct rspamd_task *task,
- GArray *args, gboolean *res)
+ GArray *args, gint *res)
{
lua_State *L = lua_data->L;
struct rspamd_task **ptask;
@@ -213,12 +215,16 @@ static gboolean rspamd_lua_call_expression_func(
}
pop++;
- if (!lua_isboolean (L, -1)) {
- lua_pop (L, pop);
+ if (lua_type (L, -1) == LUA_TNUMBER) {
+ *res = lua_tonumber (L, -1);
+ }
+ else if (lua_type (L, -1) == LUA_TBOOLEAN) {
+ *res = lua_toboolean (L, -1);
+ }
+ else {
msg_info("lua function must return a boolean");
- return FALSE;
}
- *res = lua_toboolean (L, -1);
+
lua_pop (L, pop);
return TRUE;
@@ -229,7 +235,7 @@ static void
process_regexp_item (struct rspamd_task *task, void *user_data)
{
struct regexp_module_item *item = user_data;
- gboolean res = FALSE;
+ gint res = FALSE;
/* Non-threaded version */
if (item->lua_function) {
@@ -242,7 +248,13 @@ process_regexp_item (struct rspamd_task *task, void *user_data)
}
else {
/* Process expression */
- res = rspamd_process_expression (item->expr, task);
+ if (item->expr) {
+ res = rspamd_process_expression (item->expr, task);
+ }
+ else {
+ msg_warn ("FIXME: %s symbol is broken with new expressions",
+ item->symbol);
+ }
}
if (res) {