]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Save raw headers for mime parts
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 14:49:27 +0000 (15:49 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 14:49:27 +0000 (15:49 +0100)
src/libmime/message.c
src/libmime/message.h
src/libserver/task.c

index a7a3f743915c2d88017ab4e95de54d7fbfd6f554..454a635dcc83954f00255845c961904fa52e64f2 100644 (file)
@@ -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;
index d946fa0a49b6f6c52a411e0c671767ff76c952bb..ce4d5250fccdad446c5400363a2f02d8e726170d 100644 (file)
@@ -19,6 +19,7 @@ struct mime_part {
        GMimeObject *parent;
        GMimeObject *mime;
        GHashTable *raw_headers;
+       gchar *raw_headers_str;
        gchar *checksum;
        const gchar *filename;
 };
index 8444d3fba57b382bb1822d6035696aa43920a96d..bf337cbaa323651576331352cb75d46a4ec11407 100644 (file)
@@ -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);
                        }