diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-18 14:20:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-18 14:20:48 +0100 |
commit | 3848994dbe0eb3775387960b396be75962de72dc (patch) | |
tree | 2b36c7fd894c2730ff8edd4e03039eafe1606060 /src/libserver/protocol.c | |
parent | 50b0f1819f6c260385aeee27bc8acbbe3234f389 (diff) | |
download | rspamd-3848994dbe0eb3775387960b396be75962de72dc.tar.gz rspamd-3848994dbe0eb3775387960b396be75962de72dc.zip |
Unify from/rcpt processing.
Diffstat (limited to 'src/libserver/protocol.c')
-rw-r--r-- | src/libserver/protocol.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 650becbe4..e7be5a1c3 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -232,6 +232,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, gchar *headern, *err, *tmp; gboolean res = TRUE, validh; struct rspamd_http_header *h; + InternetAddressList *tmp; LL_FOREACH (msg->headers, h) { @@ -269,8 +270,20 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, case 'f': case 'F': if (g_ascii_strcasecmp (headern, FROM_HEADER) == 0) { - task->from = rspamd_protocol_escape_braces (h->value); - debug_task ("read from header, value: %s", task->from); + task->from_envelope = internet_address_list_parse_string ( + h->value->str); + if (task->from_envelope) { +#ifdef GMIME24 + rspamd_mempool_add_destructor (task->task_pool, + (rspamd_mempool_destruct_t) g_object_unref, + task->from_envelope); +#else + rspamd_mempool_add_destructor (task->task_pool, + (rspamd_mempool_destruct_t) internet_address_list_destroy, + task->from_envelope); +#endif + } + debug_task ("read from header, value: %v", h->value); } else { debug_task ("wrong header: %s", headern); @@ -301,14 +314,18 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, case 'r': case 'R': if (g_ascii_strcasecmp (headern, RCPT_HEADER) == 0) { - tmp = rspamd_protocol_escape_braces (h->value); - task->rcpt = g_list_prepend (task->rcpt, tmp); + if (task->rcpt_envelope == NULL) { + task->rcpt_envelope = internet_address_list_new (); + } + tmp = internet_address_list_parse_string (h->value->str); + internet_address_list_append (task->rcpt_envelope, tmp); +#ifdef GMIME24 + g_object_unref (tmp); +#else + internet_address_list_destroy (tmp); +#endif debug_task ("read rcpt header, value: %s", tmp); } - else if (g_ascii_strcasecmp (headern, NRCPT_HEADER) == 0) { - task->nrcpt = strtoul (h->value->str, &err, 10); - debug_task ("read rcpt header, value: %d", (gint)task->nrcpt); - } else { msg_info ("wrong header: %s", headern); validh = FALSE; |