]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Always try to adjust filename
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Apr 2017 08:24:07 +0000 (09:24 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Apr 2017 08:24:07 +0000 (09:24 +0100)
Issue: #1591

src/libmime/mime_parser.c

index 8becc888baf38c799cae432bb5903170469d7006..d93cde835364c98667a750ca19deb69f18ab1f98 100644 (file)
@@ -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;
                        }
                }