]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Push email flags to the lua API
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Apr 2017 12:29:13 +0000 (13:29 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 1 May 2017 13:03:04 +0000 (14:03 +0100)
src/lua/lua_task.c

index 9edfd39d4b173ccb7f4f4e0a102e58bc9a73b20e..1e3a9ce3957c90f7e3a273b108f20d42f3f51a41 100644 (file)
@@ -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);
        }
 }