]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix storing of the original smtp from
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 21 Aug 2020 20:47:59 +0000 (21:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 21 Aug 2020 20:48:46 +0000 (21:48 +0100)
src/libserver/task.c
src/libserver/task.h
src/lua/lua_task.c

index 12f20f39378ae717d9e07ed0a814dd46c11629b6..53da0dae626702d3cc877cb6cbff05f9b313e7cb 100644 (file)
@@ -204,6 +204,10 @@ rspamd_task_free (struct rspamd_task *task)
                        rspamd_email_address_free (task->from_envelope);
                }
 
+               if (task->from_envelope_orig) {
+                       rspamd_email_address_free (task->from_envelope_orig);
+               }
+
                if (task->meta_words) {
                        g_array_free (task->meta_words, TRUE);
                }
index 778b77dbf0a98e107de6f237e28d9aea3ca42c90..aa6d01a2e8b9147fd236f52b8d0954e2e4f684a7 100644 (file)
@@ -190,6 +190,7 @@ struct rspamd_task {
 
        GPtrArray *rcpt_envelope;                        /**< array of rspamd_email_address                                     */
        struct rspamd_email_address *from_envelope;
+       struct rspamd_email_address *from_envelope_orig;
 
        ucl_object_t *messages;                            /**< list of messages that would be reported         */
        struct rspamd_re_runtime *re_rt;                /**< regexp runtime                                                                     */
index 09479ea215dfa402f0c22cdcd41e5fd899d108a4..6fc3768f738bbe632dd1b23afbcf89963ab30122 100644 (file)
@@ -3767,7 +3767,18 @@ lua_task_get_from (lua_State *L)
                        /* Create table to preserve compatibility */
                        if (addr->addr) {
                                lua_createtable (L, 1, 0);
-                               lua_push_email_address (L, addr);
+                               if (what & RSPAMD_ADDRESS_ORIGINAL) {
+                                       if (task->from_envelope_orig) {
+                                               lua_push_email_address (L, task->from_envelope_orig);
+                                       }
+                                       else {
+                                               lua_push_email_address (L, addr);
+                                       }
+                               }
+                               else {
+                                       lua_push_email_address (L, addr);
+                               }
+
                                lua_rawseti (L, -2, 1);
                        }
                        else {
@@ -3851,13 +3862,10 @@ lua_task_set_from (lua_State *L)
                        }
                }
                else if (paddr) {
+                       /* SMTP from case */
                        if (lua_import_email_address (L, task, 3, &addr)) {
-
-                               if (paddr) {
-                                       rspamd_email_address_free (*paddr);
-                               }
-
-                               *paddr = addr;
+                               task->from_envelope_orig = *paddr;
+                               task->from_envelope = addr;
                                lua_pushboolean (L, true);
                        }
                        else {