commit 064a12b: [Minor] Try to deal with broken CD headers

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Sep 10 19:21:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-09-10 20:18:44 +0100
URL: https://github.com/rspamd/rspamd/commit/064a12b377b10d7408b4fcf9ec7861426fb85129 (HEAD -> master)

[Minor] Try to deal with broken CD headers

---
 src/libmime/content_type.c              | 6 ++++++
 src/ragel/content_disposition_parser.rl | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c
index 88102ad2c..40f0fd351 100644
--- a/src/libmime/content_type.c
+++ b/src/libmime/content_type.c
@@ -832,6 +832,12 @@ rspamd_content_disposition_parse (const gchar *in,
 	struct rspamd_content_disposition *res = NULL, val;
 
 	if (rspamd_content_disposition_parser (in, len, &val, pool)) {
+
+		if (val.type == RSPAMD_CT_UNKNOWN) {
+			/* 'Fix' type to attachment as MUA does */
+			val.type = RSPAMD_CT_ATTACHMENT;
+		}
+
 		res = rspamd_mempool_alloc (pool, sizeof (val));
 		memcpy (res, &val, sizeof (val));
 		res->lc_data = rspamd_mempool_alloc (pool, len + 1);
diff --git a/src/ragel/content_disposition_parser.rl b/src/ragel/content_disposition_parser.rl
index cdef4db46..f1b0172b7 100644
--- a/src/ragel/content_disposition_parser.rl
+++ b/src/ragel/content_disposition_parser.rl
@@ -122,5 +122,5 @@ rspamd_content_disposition_parser (const char *data, size_t len, struct rspamd_c
     free (st_storage.data);
   }
 
-  return cd->type != RSPAMD_CT_UNKNOWN;
+  return cd->attrs != NULL || cd->type != RSPAMD_CT_UNKNOWN;
 }


More information about the Commits mailing list