commit 0e7eeb5: [Fix] Restore support for `for` and `id` parts in received headers

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jul 27 15:28:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-07-27 16:10:21 +0100
URL: https://github.com/rspamd/rspamd/commit/0e7eeb52add2e905fd935043b6a80519f283ef91

[Fix] Restore support for `for` and `id` parts in received headers

---
 src/libmime/mime_headers.c | 18 ++++++++++++++++++
 src/libmime/mime_headers.h |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index fec23927e..de4184bb9 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -906,6 +906,7 @@ enum rspamd_received_part_type {
 	RSPAMD_RECEIVED_PART_BY,
 	RSPAMD_RECEIVED_PART_FOR,
 	RSPAMD_RECEIVED_PART_WITH,
+	RSPAMD_RECEIVED_PART_ID,
 	RSPAMD_RECEIVED_PART_UNKNOWN,
 };
 
@@ -1238,6 +1239,12 @@ rspamd_smtp_received_spill (struct rspamd_task *task,
 				cur_part = rspamd_smtp_received_process_part (task, p, end - p,
 						RSPAMD_RECEIVED_PART_FOR, &pos);
 			}
+			else if (len > sizeof ("id") && (lc_map[p[0]] == 'i' &&
+											  lc_map[p[1]] == 'd')) {
+				p += sizeof ("id") - 1;
+				cur_part = rspamd_smtp_received_process_part (task, p, end - p,
+						RSPAMD_RECEIVED_PART_ID, &pos);
+			}
 			else {
 				while (p < end) {
 					if (!(g_ascii_isspace (*p) || *p == '(' || *p == ';')) {
@@ -1614,6 +1621,17 @@ rspamd_smtp_received_parse (struct rspamd_task *task,
 				}
 			}
 
+			break;
+		case RSPAMD_RECEIVED_PART_FOR:
+			rh->for_addr = rspamd_email_address_from_smtp (cur->data, cur->dlen);
+
+			if (rh->for_addr) {
+				rh->for_mbox = rh->for_addr->addr;
+
+				rspamd_mempool_add_destructor (task->task_pool,
+						(rspamd_mempool_destruct_t)rspamd_email_address_free,
+						rh->for_addr);
+			}
 			break;
 		default:
 			/* Do nothing */
diff --git a/src/libmime/mime_headers.h b/src/libmime/mime_headers.h
index 18d23d662..56e29e9f9 100644
--- a/src/libmime/mime_headers.h
+++ b/src/libmime/mime_headers.h
@@ -95,6 +95,8 @@ enum rspamd_received_type {
 			RSPAMD_RECEIVED_MAPI| \
 			RSPAMD_RECEIVED_UNKNOWN)
 
+struct rspamd_email_address;
+
 struct rspamd_received_header {
 	const gchar *from_hostname;
 	const gchar *from_ip;
@@ -102,6 +104,7 @@ struct rspamd_received_header {
 	const gchar *real_ip;
 	const gchar *by_hostname;
 	const gchar *for_mbox;
+	struct rspamd_email_address *for_addr;
 	rspamd_inet_addr_t *addr;
 	struct rspamd_mime_header *hdr;
 	time_t timestamp;


More information about the Commits mailing list