]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Replies: Fix 'Reply-To' handling in task:get_reply_sender
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 20 Apr 2021 13:36:41 +0000 (14:36 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 20 Apr 2021 13:36:41 +0000 (14:36 +0100)
src/lua/lua_task.c

index cb9ca49944826d50b68b308dafa6747b281fb0f5..01c4504224c92485fa407dc8477b7ff526013235 100644 (file)
@@ -4103,10 +4103,23 @@ lua_task_get_reply_sender (lua_State *L)
 
        if (task) {
 
-               rh = rspamd_message_get_header_array(task, "Reply-To", FALSE);
+               rh = rspamd_message_get_header_array (task, "Reply-To", FALSE);
 
                if (rh) {
-                       lua_pushstring (L, rh->decoded);
+                       GPtrArray *addrs;
+
+                       addrs = rspamd_email_address_from_mime (task->task_pool, rh->decoded,
+                                       strlen (rh->decoded), NULL, -1);
+
+                       if (addrs == NULL) {
+                               lua_pushnil (L);
+                       }
+                       else {
+                               struct rspamd_email_address *addr;
+
+                               addr = (struct rspamd_email_address *)g_ptr_array_index (addrs, 0);
+                               lua_pushlstring (L, addr->addr, addr->addr_len);
+                       }
                }
                else if (MESSAGE_FIELD_CHECK (task, from_mime) &&
                                MESSAGE_FIELD (task, from_mime)->len == 1) {