From 6d27d22f08e2dcabe2b3a5122f3478d45fc3cf66 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 31 Mar 2016 14:38:45 +0100 Subject: [PATCH] [Feature] Allow tables in task:insert_result --- src/lua/lua_task.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index d193cdbc6..003c4f086 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -844,10 +844,26 @@ lua_task_insert_result (lua_State * L) top = lua_gettop (L); /* Get additional options */ for (i = 4; i <= top; i++) { - param = luaL_checkstring (L, i); - params = - g_list_prepend (params, - rspamd_mempool_strdup (task->task_pool, param)); + if (lua_type (L, i) == LUA_TSTRING) { + param = luaL_checkstring (L, i); + params = + g_list_prepend (params, + rspamd_mempool_strdup (task->task_pool, param)); + } + else if (lua_type (L, i) == LUA_TTABLE) { + lua_pushvalue (L, i); + lua_pushnil (L); + + while (lua_next (L, -2)) { + param = lua_tostring (L, -1); + params = g_list_prepend (params, + rspamd_mempool_strdup (task->task_pool, + param)); + lua_pop (L, 1); + } + + lua_pop (L, 1); + } } rspamd_task_insert_result (task, symbol_name, flag, params); -- 2.39.5