commit 82c42eb: [Fix] Fix rfc2047 embedded into rfc2231 pieces in special headers

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Mar 30 19:35:07 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-03-30 20:30:28 +0100
URL: https://github.com/rspamd/rspamd/commit/82c42eb32e48137b3c5c0f3ffb393a17a8e30f78 (HEAD -> master)

[Fix] Fix rfc2047 embedded into rfc2231 pieces in special headers

---
 src/libmime/content_type.c | 12 +++++++++++-
 src/libmime/mime_parser.c  | 10 +++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c
index 84a93602f..7c0ff3743 100644
--- a/src/libmime/content_type.c
+++ b/src/libmime/content_type.c
@@ -226,6 +226,16 @@ rspamd_postprocess_ct_attributes (rspamd_mempool_t *pool,
 			param->prev = param;
 		}
 
+		gboolean invalid_utf = FALSE;
+
+		param->value.begin = rspamd_mime_header_decode (pool, param->value.begin,
+				param->value.len, &invalid_utf);
+		param->value.len = strlen (param->value.begin);
+
+		if (invalid_utf) {
+			param->flags |= RSPAMD_CONTENT_PARAM_BROKEN;
+		}
+
 		proc (pool, param, procd);
 	}
 }
@@ -269,7 +279,7 @@ rspamd_content_type_postprocess (rspamd_mempool_t *pool,
 		RSPAMD_FTOK_ASSIGN (&srch, "name");
 		if (!rspamd_ftok_icase_equal (&param->name, &srch)) {
 			/* Just lowercase */
-			rspamd_str_lc ((gchar *) param->value.begin, param->value.len);
+			rspamd_str_lc_utf8 ((gchar *) param->value.begin, param->value.len);
 		}
 	}
 }
diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c
index a89b76b3a..0363d4514 100644
--- a/src/libmime/mime_parser.c
+++ b/src/libmime/mime_parser.c
@@ -501,9 +501,9 @@ rspamd_mime_part_get_cd (struct rspamd_task *task, struct rspamd_mime_part *part
 			gsize hlen;
 			cd = NULL;
 
-			if (cur->decoded) {
-				hlen = strlen (cur->decoded);
-				cd = rspamd_content_disposition_parse (cur->decoded, hlen,
+			if (cur->value) {
+				hlen = strlen (cur->value);
+				cd = rspamd_content_disposition_parse (cur->value, hlen,
 						task->task_pool);
 			}
 
@@ -887,7 +887,7 @@ rspamd_mime_process_multipart_node (struct rspamd_task *task,
 	if (hdr != NULL) {
 
 		DL_FOREACH (hdr, cur) {
-			ct = rspamd_content_type_parse (cur->decoded, strlen (cur->decoded),
+			ct = rspamd_content_type_parse (cur->value, strlen (cur->value),
 					task->task_pool);
 
 			/* Here we prefer multipart content-type or any content-type */
@@ -1521,7 +1521,7 @@ rspamd_mime_parse_message (struct rspamd_task *task,
 	}
 	else {
 		DL_FOREACH (hdr, cur) {
-			ct = rspamd_content_type_parse (cur->decoded, strlen (cur->decoded),
+			ct = rspamd_content_type_parse (cur->value, strlen (cur->value),
 					task->task_pool);
 
 			/* Here we prefer multipart content-type or any content-type */


More information about the Commits mailing list