]> source.dussan.org Git - rspamd.git/commitdiff
Set useful fields for addresses.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 16 Aug 2014 18:41:15 +0000 (19:41 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 16 Aug 2014 18:41:15 +0000 (19:41 +0100)
src/lua/lua_task.c

index 84ef211be06c966da63dcbf3acc024ac413c3a07..39b6a2041e8d6acfd755929bcceaba2afb7730c1 100644 (file)
@@ -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
 }