From 803bfde8ef09ac498f882ae57adb36c29f9ea591 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 29 Mar 2016 16:57:09 +0100 Subject: [PATCH] [Feature] Improve processing of headers to lua --- src/lua/lua_task.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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); -- 2.39.5