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;
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;
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)
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,
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;
c = SPAM_SUBJECT;
}
- s = g_mime_message_get_subject (task->message);
+ s = task->subject;
while (p < end) {
if (*c == '\0') {
}
p++;
}
+
res = g_mime_utils_header_encode_text (subj_buf);
rspamd_mempool_add_destructor (task->task_pool,
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);
}
/* 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 {
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 *)"";
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);
+ }
}
}