From: Vsevolod Stakhov Date: Mon, 11 Apr 2016 14:49:27 +0000 (+0100) Subject: [Feature] Save raw headers for mime parts X-Git-Tag: 1.2.3~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=81929c5b676724321a3265a76467bc29c68aeade;p=rspamd.git [Feature] Save raw headers for mime parts --- diff --git a/src/libmime/message.c b/src/libmime/message.c index a7a3f7439..454a635dc 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -1349,13 +1349,11 @@ mime_foreach_callback (GMimeObject * part, gpointer user_data) hdrs = g_mime_object_get_headers (GMIME_OBJECT (part)); mime_part->raw_headers = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal); - rspamd_mempool_add_destructor (task->task_pool, - (rspamd_mempool_destruct_t) g_hash_table_unref, - mime_part->raw_headers); + if (hdrs != NULL) { process_raw_headers (task, mime_part->raw_headers, hdrs, strlen (hdrs)); - g_free (hdrs); + mime_part->raw_headers_str = hdrs; } mime_part->type = type; @@ -1415,13 +1413,11 @@ mime_foreach_callback (GMimeObject * part, gpointer user_data) hdrs = g_mime_object_get_headers (GMIME_OBJECT (part)); mime_part->raw_headers = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal); - rspamd_mempool_add_destructor (task->task_pool, - (rspamd_mempool_destruct_t) g_hash_table_unref, - mime_part->raw_headers); + if (hdrs != NULL) { process_raw_headers (task, mime_part->raw_headers, hdrs, strlen (hdrs)); - g_free (hdrs); + mime_part->raw_headers_str = hdrs; } mime_part->type = type; diff --git a/src/libmime/message.h b/src/libmime/message.h index d946fa0a4..ce4d5250f 100644 --- a/src/libmime/message.h +++ b/src/libmime/message.h @@ -19,6 +19,7 @@ struct mime_part { GMimeObject *parent; GMimeObject *mime; GHashTable *raw_headers; + gchar *raw_headers_str; gchar *checksum; const gchar *filename; }; diff --git a/src/libserver/task.c b/src/libserver/task.c index 8444d3fba..bf337cbaa 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -170,10 +170,19 @@ rspamd_task_free (struct rspamd_task *task) for (i = 0; i < task->parts->len; i ++) { p = g_ptr_array_index (task->parts, i); g_byte_array_free (p->content, TRUE); + + if (p->raw_headers_str) { + g_free (p->raw_headers_str); + } + + if (p->raw_headers) { + g_hash_table_unref (p->raw_headers); + } } for (i = 0; i < task->text_parts->len; i ++) { tp = g_ptr_array_index (task->text_parts, i); + if (tp->normalized_words) { g_array_free (tp->normalized_words, TRUE); }