From: Vsevolod Stakhov Date: Thu, 31 Mar 2016 13:38:45 +0000 (+0100) Subject: [Feature] Allow tables in task:insert_result X-Git-Tag: 1.2.2~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6d27d22f08e2dcabe2b3a5122f3478d45fc3cf66;p=rspamd.git [Feature] Allow tables in task:insert_result --- 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);