commit d1cab3e: [Fix] Fix storing of the original smtp from
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Aug 21 20:49:08 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-08-21 21:47:59 +0100
URL: https://github.com/rspamd/rspamd/commit/d1cab3edeef224d8d2611087d4fa12623e68165d (HEAD -> master)
[Fix] Fix storing of the original smtp from
---
src/libserver/task.c | 4 ++++
src/libserver/task.h | 1 +
src/lua/lua_task.c | 22 +++++++++++++++-------
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 12f20f393..53da0dae6 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -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);
}
diff --git a/src/libserver/task.h b/src/libserver/task.h
index 778b77dbf..aa6d01a2e 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -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 */
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 09479ea21..6fc3768f7 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -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 {
More information about the Commits
mailing list