aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libmime/message.h10
-rw-r--r--src/libmime/mime_parser.c6
-rw-r--r--src/libserver/protocol.c8
-rw-r--r--src/libserver/re_cache.c10
-rw-r--r--src/libserver/task.c7
5 files changed, 24 insertions, 17 deletions
diff --git a/src/libmime/message.h b/src/libmime/message.h
index 66981ca9e..c4f0e7a8e 100644
--- a/src/libmime/message.h
+++ b/src/libmime/message.h
@@ -36,6 +36,10 @@ enum rspamd_cte {
struct rspamd_mime_text_part;
+struct rspamd_mime_multipart {
+ GPtrArray *children;
+};
+
struct rspamd_mime_part {
struct rspamd_content_type *ct;
struct rspamd_content_disposition *cd;
@@ -48,7 +52,7 @@ struct rspamd_mime_part {
enum rspamd_cte cte;
union {
- struct rspamd_mime_multipart *mp;
+ struct rspamd_mime_multipart mp;
struct rspamd_mime_text_part *txt;
struct rspamd_image *img;
struct rspamd_archive *arch;
@@ -58,10 +62,6 @@ struct rspamd_mime_part {
guchar digest[rspamd_cryptobox_HASHBYTES];
};
-struct rspamd_mime_multipart {
- GPtrArray *children;
-};
-
#define RSPAMD_MIME_TEXT_PART_FLAG_UTF (1 << 0)
#define RSPAMD_MIME_TEXT_PART_FLAG_BALANCED (1 << 1)
#define RSPAMD_MIME_TEXT_PART_FLAG_EMPTY (1 << 2)
diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c
index 7586a803e..0b192b8d5 100644
--- a/src/libmime/mime_parser.c
+++ b/src/libmime/mime_parser.c
@@ -341,8 +341,8 @@ rspamd_mime_process_multipart_node (struct rspamd_task *task,
hdr_pos = rspamd_string_find_eoh (&str, &body_pos);
- if (multipart->children == NULL) {
- multipart->children = g_ptr_array_sized_new (2);
+ if (multipart->specific.mp.children == NULL) {
+ multipart->specific.mp.children = g_ptr_array_sized_new (2);
}
npart = rspamd_mempool_alloc0 (task->task_pool,
@@ -350,7 +350,7 @@ rspamd_mime_process_multipart_node (struct rspamd_task *task,
npart->parent_part = multipart;
npart->raw_headers = g_hash_table_new_full (rspamd_strcase_hash,
rspamd_strcase_equal, NULL, rspamd_ptr_array_free_hard);
- g_ptr_array_add (multipart->children, npart);
+ g_ptr_array_add (multipart->specific.mp.children, npart);
if (hdr_pos > 0 && hdr_pos < str.len) {
npart->raw_headers_str = str.str;
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index a1a1ae8fe..cdc7f263a 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -778,7 +778,7 @@ make_rewritten_subject (struct rspamd_metric *metric, struct rspamd_task *task)
c = SPAM_SUBJECT;
}
- s = g_mime_message_get_subject (task->message);
+ s = task->subject;
while (p < end) {
if (*c == '\0') {
@@ -794,6 +794,7 @@ make_rewritten_subject (struct rspamd_metric *metric, struct rspamd_task *task)
}
p++;
}
+
res = g_mime_utils_header_encode_text (subj_buf);
rspamd_mempool_add_destructor (task->task_pool,
@@ -897,8 +898,11 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
if (action == METRIC_ACTION_REWRITE_SUBJECT) {
subject = make_rewritten_subject (m, task);
- ucl_object_insert_key (obj, ucl_object_fromstring (subject),
+
+ if (subject) {
+ ucl_object_insert_key (obj, ucl_object_fromstring (subject),
"subject", 0, false);
+ }
}
/* Now handle symbols */
g_hash_table_iter_init (&hiter, mres->symbols);
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index 1e713dc86..e5298ff04 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -884,8 +884,8 @@ rspamd_re_cache_exec_re (struct rspamd_task *task,
}
/* Select data for regexp */
if (re_class->type == RSPAMD_RE_RAWMIME) {
- in = part->raw->data;
- len = part->raw->len;
+ in = part->raw.begin;
+ len = part->raw.len;
raw = TRUE;
}
else {
@@ -1022,9 +1022,9 @@ rspamd_re_cache_exec_re (struct rspamd_task *task,
for (i = 0; i < task->text_parts->len; i++) {
part = g_ptr_array_index (task->text_parts, i);
- if (part->orig) {
- scvec[i] = (guchar *)part->orig->data;
- lenvec[i] = part->orig->len;
+ if (part->parsed.len > 0) {
+ scvec[i] = (guchar *)part->parsed.begin;
+ lenvec[i] = part->parsed.len;
}
else {
scvec[i] = (guchar *)"";
diff --git a/src/libserver/task.c b/src/libserver/task.c
index cee604acd..656e177aa 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -203,8 +203,11 @@ rspamd_task_free (struct rspamd_task *task)
if (p->raw_headers) {
g_hash_table_unref (p->raw_headers);
}
- if (p->children) {
- g_ptr_array_free (p->children, TRUE);
+
+ if (IS_CT_MULTIPART (p->ct)) {
+ if (p->specific.mp.children) {
+ g_ptr_array_free (p->specific.mp.children, TRUE);
+ }
}
}