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 {
}
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);
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));
}
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);
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 {