From: Vsevolod Stakhov Date: Tue, 25 Apr 2017 12:29:13 +0000 (+0100) Subject: [Minor] Push email flags to the lua API X-Git-Tag: 1.5.7~14 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dfe99d902f16766d56a7537385e80220d1383300;p=rspamd.git [Minor] Push email flags to the lua API --- diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 9edfd39d4..1e3a9ce39 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1987,6 +1987,14 @@ lua_task_str_to_get_type (lua_State *L, gint pos) return ret; } +#define EMAIL_CHECK_FLAG(fl, str) do { \ + if (addr->flags & (fl)) { \ + lua_pushstring (L, (str)); \ + lua_pushboolean (L, true); \ + lua_settable (L, -3); \ + } \ +} while(0) + static void lua_push_email_address (lua_State *L, struct rspamd_email_address *addr) { @@ -2034,6 +2042,19 @@ lua_push_email_address (lua_State *L, struct rspamd_email_address *addr) lua_pushstring (L, ""); lua_settable (L, -3); } + + lua_pushstring (L, "flags"); + lua_createtable (L, 0, 7); + + EMAIL_CHECK_FLAG (RSPAMD_EMAIL_ADDR_VALID, "valid"); + EMAIL_CHECK_FLAG (RSPAMD_EMAIL_ADDR_IP, "ip"); + EMAIL_CHECK_FLAG (RSPAMD_EMAIL_ADDR_BRACED, "braced"); + EMAIL_CHECK_FLAG (RSPAMD_EMAIL_ADDR_QUOTED, "quoted"); + EMAIL_CHECK_FLAG (RSPAMD_EMAIL_ADDR_EMPTY, "empty"); + EMAIL_CHECK_FLAG (RSPAMD_EMAIL_ADDR_HAS_BACKSLASH, "backslash"); + EMAIL_CHECK_FLAG (RSPAMD_EMAIL_ADDR_HAS_8BIT, "8bit"); + + lua_settable (L, -3); } }