From 7d2447448cbcf025f5152a7091e648b00416a92a Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 19 Apr 2018 15:00:48 +0100 Subject: [PATCH] [Feature] Support recipients separated by commas --- src/libserver/protocol.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index c7e693e31..7f12e3883 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -316,19 +316,39 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, case 'r': case 'R': IF_HEADER (RCPT_HEADER) { - addr = rspamd_email_address_from_smtp (hv->str, hv->len); + const gchar *p, *end; + gsize cur_len; - if (addr) { - if (task->rcpt_envelope == NULL) { - task->rcpt_envelope = g_ptr_array_sized_new (2); + p = hv->str; + end = p + hv->len; + + while (p < end) { + cur_len = rspamd_memcspn (p, ",", end - p); + + if (cur_len > 0) { + addr = rspamd_email_address_from_smtp (p, cur_len); + + if (addr) { + if (task->rcpt_envelope == NULL) { + task->rcpt_envelope = g_ptr_array_sized_new ( + 2); + } + + g_ptr_array_add (task->rcpt_envelope, addr); + } else { + msg_err_protocol ("bad rcpt header: '%T'", + &h->value); + task->flags |= RSPAMD_TASK_FLAG_BROKEN_HEADERS; + } + + p += cur_len; } - g_ptr_array_add (task->rcpt_envelope, addr); - } - else { - msg_err_protocol ("bad rcpt header: '%T'", &h->value); - task->flags |= RSPAMD_TASK_FLAG_BROKEN_HEADERS; + while (p < end && *p == ',') { + p ++; + } } + msg_debug_protocol ("read rcpt header, value: %V", hv); } else { -- 2.39.5