From 560d27b0de840d090666d295b0444c070f2c0a19 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 14 Apr 2017 09:24:07 +0100 Subject: [PATCH] [Fix] Always try to adjust filename Issue: #1591 --- src/libmime/mime_parser.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c index 8becc888b..d93cde835 100644 --- a/src/libmime/mime_parser.c +++ b/src/libmime/mime_parser.c @@ -340,7 +340,6 @@ rspamd_mime_part_get_cd (struct rspamd_task *task, struct rspamd_mime_part *part memcpy (&cd->filename, &found->value, sizeof (cd->filename)); } } - } else { for (i = 0; i < hdrs->len; i ++) { @@ -354,6 +353,25 @@ rspamd_mime_part_get_cd (struct rspamd_task *task, struct rspamd_mime_part *part if (cd) { msg_debug_mime ("processed content disposition: %s", cd->lc_data); + + /* We still need to check filename */ + if (cd->filename.len == 0) { + if (part->ct && 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)); + } + } + } break; } } -- 2.39.5