aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-07 14:13:32 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-07 14:13:32 +0100
commit311582f4fd281b213ad9f19beff9d1fe8c1345cc (patch)
tree250a9d5cd17bb68b32b4c60ab2d5e7a4100158f0
parent3e40b90c1f443bad865d54ea488c8d12a063fd2d (diff)
downloadrspamd-311582f4fd281b213ad9f19beff9d1fe8c1345cc.tar.gz
rspamd-311582f4fd281b213ad9f19beff9d1fe8c1345cc.zip
Improve regexp items parsing diagnostics.
-rw-r--r--src/libmime/mime_expressions.c15
-rw-r--r--src/plugins/regexp.c6
2 files changed, 17 insertions, 4 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c
index 2167f2832..438d7347f 100644
--- a/src/libmime/mime_expressions.c
+++ b/src/libmime/mime_expressions.c
@@ -505,6 +505,7 @@ rspamd_mime_expr_parse (const gchar *line, gsize len,
rspamd_expression_atom_t *a = NULL;
struct rspamd_mime_atom *mime_atom = NULL;
const gchar *p, *end;
+ struct rspamd_config *cfg = ud;
gchar t;
gint type = MIME_ATOM_REGEXP, obraces = 0, ebraces = 0;
enum {
@@ -636,6 +637,17 @@ set:
}
else if (type == MIME_ATOM_LUA_FUNCTION) {
mime_atom->d.lua_function = mime_atom->str;
+
+ lua_getglobal (cfg->lua_state, mime_atom->str);
+
+ if (lua_type (cfg->lua_state, -1) != LUA_TFUNCTION) {
+ g_set_error (err, rspamd_mime_expr_quark(), 200, "no such lua function '%s'",
+ mime_atom->str);
+ lua_pop (cfg->lua_state, 1);
+
+ goto err;
+ }
+ lua_pop (cfg->lua_state, 1);
}
else {
mime_atom->d.func = rspamd_mime_expr_parse_function_atom (mime_atom->str);
@@ -1064,7 +1076,8 @@ rspamd_mime_expr_process (gpointer input, rspamd_expression_atom_t *atom)
rspamd_lua_task_push (L, task);
if (lua_pcall (L, 1, 1, 0) != 0) {
- msg_info ("call to %s failed: %s",
+ msg_info ("lua call to global function '%s' for atom '%s' failed: %s",
+ mime_atom->d.lua_function,
mime_atom->str,
lua_tostring (L, -1));
}
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 30824949d..27cbf924f 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -71,12 +71,12 @@ read_regexp_expression (rspamd_mempool_t * pool,
struct regexp_module_item *chain,
const gchar *symbol,
const gchar *line,
- gboolean raw_mode)
+ struct rspamd_config *cfg)
{
struct rspamd_expression *e = NULL;
GError *err = NULL;
- if (!rspamd_parse_expression (line, 0, &mime_expr_subr, NULL, pool, &err,
+ if (!rspamd_parse_expression (line, 0, &mime_expr_subr, cfg, pool, &err,
&e)) {
msg_warn ("%s = \"%s\" is invalid regexp expression: %e", symbol, line,
err);
@@ -137,7 +137,7 @@ regexp_module_config (struct rspamd_config *cfg)
cur_item->symbol = ucl_object_key (value);
if (!read_regexp_expression (regexp_module_ctx->regexp_pool,
cur_item, ucl_object_key (value),
- ucl_obj_tostring (value), cfg->raw_mode)) {
+ ucl_obj_tostring (value), cfg)) {
res = FALSE;
}
else {