diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-16 19:41:15 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-16 19:41:15 +0100 |
commit | 8632d14d4b43f2da3cfefdf76b211f4c3449a392 (patch) | |
tree | b6f7ab0c5433c9c8a96ec7b8a4a0a7ca59058623 /src/lua/lua_task.c | |
parent | 606bb74d131c04d399b2476a91edd69000313855 (diff) | |
download | rspamd-8632d14d4b43f2da3cfefdf76b211f4c3449a392.tar.gz rspamd-8632d14d4b43f2da3cfefdf76b211f4c3449a392.zip |
Set useful fields for addresses.
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r-- | src/lua/lua_task.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 84ef211be..39b6a2041 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -789,14 +789,29 @@ lua_push_internet_address (lua_State *L, InternetAddress *ia) return FALSE; #else InternetAddressMailbox *iamb; + const char *addr, *at; if (ia && INTERNET_ADDRESS_IS_MAILBOX (ia)) { lua_newtable (L); iamb = INTERNET_ADDRESS_MAILBOX (ia); - lua_set_table_index (L, "name", internet_address_get_name (ia)); - lua_set_table_index (L, "addr", - internet_address_mailbox_get_addr (iamb)); - return TRUE; + addr = internet_address_mailbox_get_addr (iamb); + if (addr) { + lua_set_table_index (L, "name", internet_address_get_name (ia)); + lua_set_table_index (L, "addr", addr); + /* Set optional fields */ + + at = strchr (addr, '@'); + if (at != NULL) { + lua_pushstring(L, "user"); + lua_pushlstring(L, addr, at - addr); + lua_settable (L, -3); + lua_pushstring(L, "domain"); + lua_pushstring(L, at + 1); + lua_settable (L, -3); + } + return TRUE; + } } + return FALSE; #endif } |