aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-09 15:03:42 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-09 15:03:42 +0000
commitf001e86f0b8618ca47d11edf5508a6cc4b34976c (patch)
tree298f47251b822fe82e21f3f1e594d7c859dfabc1 /src
parent628c70f017b2bd30d82ed33d2601d889e9f19506 (diff)
downloadrspamd-f001e86f0b8618ca47d11edf5508a6cc4b34976c.tar.gz
rspamd-f001e86f0b8618ca47d11edf5508a6cc4b34976c.zip
[Minor] Try to get filename from CT if CD header is broken
Diffstat (limited to 'src')
-rw-r--r--src/libmime/mime_parser.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c
index 7b38b80b1..18c54d13b 100644
--- a/src/libmime/mime_parser.c
+++ b/src/libmime/mime_parser.c
@@ -448,6 +448,30 @@ rspamd_mime_part_get_cd (struct rspamd_task *task, struct rspamd_mime_part *part
cd->lc_data, &cd->filename);
break;
}
+ else if (part->ct) {
+ /*
+ * Even in case of malformed Content-Disposition, we can still
+ * fall back to Content-Type
+ */
+ cd = rspamd_mempool_alloc0 (task->task_pool, sizeof (*cd));
+ cd->type = RSPAMD_CT_INLINE;
+
+ /* We can also have content dispositon definitions in Content-Type */
+ if (part->ct->attrs) {
+ RSPAMD_FTOK_ASSIGN (&srch, "name");
+ found = g_hash_table_lookup (part->ct->attrs, &srch);
+
+ if (!found) {
+ RSPAMD_FTOK_ASSIGN (&srch, "filename");
+ found = g_hash_table_lookup (part->ct->attrs, &srch);
+ }
+
+ if (found) {
+ cd->type = RSPAMD_CT_ATTACHMENT;
+ memcpy (&cd->filename, &found->value, sizeof (cd->filename));
+ }
+ }
+ }
}
}