aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-11 15:49:27 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-11 15:49:27 +0100
commit81929c5b676724321a3265a76467bc29c68aeade (patch)
tree691483a2981980b7479e244522ba7e7fccb0f88d /src
parentd8c5060dc65e3baf7b3b94dece4251a457449aa8 (diff)
downloadrspamd-81929c5b676724321a3265a76467bc29c68aeade.tar.gz
rspamd-81929c5b676724321a3265a76467bc29c68aeade.zip
[Feature] Save raw headers for mime parts
Diffstat (limited to 'src')
-rw-r--r--src/libmime/message.c12
-rw-r--r--src/libmime/message.h1
-rw-r--r--src/libserver/task.c9
3 files changed, 14 insertions, 8 deletions
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);
}