aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_parser.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-29 16:57:46 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-29 17:02:39 +0100
commitf92898a226c163e8084c3ffd9fff83ccdd66a802 (patch)
treea696edd4c024d57daa9d3292de3530b067cc251b /src/libmime/mime_parser.c
parent5f026c6984811b4109ca197f471d13978bcdc65e (diff)
downloadrspamd-f92898a226c163e8084c3ffd9fff83ccdd66a802.tar.gz
rspamd-f92898a226c163e8084c3ffd9fff83ccdd66a802.zip
[Feature] Allow to process filenames from content type
Diffstat (limited to 'src/libmime/mime_parser.c')
-rw-r--r--src/libmime/mime_parser.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c
index f36b4848b..e994dc795 100644
--- a/src/libmime/mime_parser.c
+++ b/src/libmime/mime_parser.c
@@ -313,6 +313,7 @@ rspamd_mime_part_get_cd (struct rspamd_task *task, struct rspamd_mime_part *part
guint i;
GPtrArray *hdrs;
struct rspamd_content_disposition *cd = NULL;
+ rspamd_ftok_t srch, *found;
hdrs = rspamd_message_get_header_from_hash (part->raw_headers,
task->task_pool,
@@ -322,6 +323,23 @@ rspamd_mime_part_get_cd (struct rspamd_task *task, struct rspamd_mime_part *part
if (hdrs == NULL) {
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) {
+ 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, sizeof (cd->filename));
+ }
+ }
+
}
else {
for (i = 0; i < hdrs->len; i ++) {