aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-14 12:33:37 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-14 13:42:48 +0000
commite415626203bec3746f7ce9d4d6681e3b938dd05d (patch)
treee48ba3b1831bea23cefb2653ec268f114c1953c0
parent46a2f8f727818c84bf2fd45c30c20bac02e80b2a (diff)
downloadrspamd-e415626203bec3746f7ce9d4d6681e3b938dd05d.tar.gz
rspamd-e415626203bec3746f7ce9d4d6681e3b938dd05d.zip
[Minor] More features to mime parser
-rw-r--r--src/libmime/message.h2
-rw-r--r--src/libmime/mime_parser.c17
2 files changed, 17 insertions, 2 deletions
diff --git a/src/libmime/message.h b/src/libmime/message.h
index 3dd32c4db..b6a1f998f 100644
--- a/src/libmime/message.h
+++ b/src/libmime/message.h
@@ -38,6 +38,8 @@ struct rspamd_mime_part {
struct rspamd_content_type *ct;
rspamd_ftok_t raw_data;
rspamd_ftok_t parsed_data;
+ struct rspamd_mime_part *parent_part;
+ GPtrArray *children;
enum rspamd_cte cte;
GByteArray *content;
GMimeObject *parent;
diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c
index 27eedb644..782eca784 100644
--- a/src/libmime/mime_parser.c
+++ b/src/libmime/mime_parser.c
@@ -257,6 +257,7 @@ rspamd_mime_parse_normal_part (struct rspamd_task *task,
g_assert_not_reached ();
}
+ g_ptr_array_add (task->parts, part);
msg_debug_mime ("parsed data part %T/%T of length %z (%z orig), %s cte",
&part->ct->type, &part->ct->subtype, part->parsed_data.len,
part->raw_data.len, rspamd_cte_to_string (part->cte));
@@ -294,9 +295,15 @@ rspamd_mime_process_multipart_node (struct rspamd_task *task,
str.len = end - start;
hdr_pos = rspamd_string_find_eoh (&str, &body_pos);
+
+ if (multipart->children == NULL) {
+ multipart->children = g_ptr_array_sized_new (2);
+ }
+
npart = rspamd_mempool_alloc0 (task->task_pool,
sizeof (struct rspamd_mime_part));
- npart->parent = multipart;
+ npart->parent_part = multipart;
+ g_ptr_array_add (multipart->children, npart);
if (hdr_pos > 0 && hdr_pos < str.len) {
@@ -492,6 +499,8 @@ rspamd_mime_parse_multipart_part (struct rspamd_task *task,
return FALSE;
}
+ g_ptr_array_add (task->parts, part);
+
cbdata.multipart = part;
cbdata.task = task;
cbdata.st = st;
@@ -536,6 +545,10 @@ rspamd_mime_parse_message (struct rspamd_task *task,
return FALSE;
}
+ if (part) {
+ g_ptr_array_add (task->parts, part);
+ }
+
/* Parse headers */
if (st->cur_part == NULL) {
p = task->msg.begin;
@@ -676,7 +689,7 @@ rspamd_mime_parse_message (struct rspamd_task *task,
sizeof (struct rspamd_mime_part));
npart->raw_data.begin = pbegin;
npart->raw_data.len = plen;
- npart->parent = part;
+ npart->parent_part = part;
npart->ct = sel;
if (st->cur_part == NULL) {