From: Vsevolod Stakhov Date: Tue, 29 Mar 2016 15:57:09 +0000 (+0100) Subject: [Feature] Improve processing of headers to lua X-Git-Tag: 1.2.2~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=803bfde8ef09ac498f882ae57adb36c29f9ea591;p=rspamd.git [Feature] Improve processing of headers to lua --- diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 82ac79288..298a2f154 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -21,6 +21,7 @@ #include "util.h" #include "images.h" #include "cfg_file.h" +#include "utlist.h" /*** * @module rspamd_task @@ -1173,7 +1174,7 @@ rspamd_lua_push_header (lua_State * L, gboolean raw) { - struct raw_header *rh; + struct raw_header *rh, *cur; gint i = 1; const gchar *val; @@ -1185,9 +1186,16 @@ rspamd_lua_push_header (lua_State * L, } if (full) { - lua_newtable (L); + i = 0; + LL_FOREACH (rh, cur) { + i ++; + } + + lua_createtable (L, i, 0); } + i = 1; + while (rh) { if (rh->name == NULL) { rh = rh->next; @@ -1202,7 +1210,7 @@ rspamd_lua_push_header (lua_State * L, } if (full) { /* Create new associated table for a header */ - lua_newtable (L); + lua_createtable (L, 0, 6); rspamd_lua_table_set (L, "name", rh->name); if (rh->value) { rspamd_lua_table_set (L, "value", rh->value);