commit 8b18d03: [Fix] Fix html attachments checks

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Oct 22 12:07:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-10-22 13:02:36 +0100
URL: https://github.com/rspamd/rspamd/commit/8b18d032b394d1873eb16e28e7caae9f6d8fe9c1 (HEAD -> master)

[Fix] Fix html attachments checks

---
 src/libmime/message.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/libmime/message.c b/src/libmime/message.c
index 15a24b934..2702d0f51 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -779,13 +779,12 @@ rspamd_message_process_text_part_maybe (struct rspamd_task *task,
 {
 	struct rspamd_mime_text_part *text_part;
 	rspamd_ftok_t html_tok, xhtml_tok;
-	gboolean found_html = FALSE, found_txt = FALSE, straight_ct = FALSE;
+	gboolean found_html = FALSE, found_txt = FALSE;
 	enum rspamd_action_type act;
 
-	if (((mime_part->ct && (mime_part->ct->flags & RSPAMD_CONTENT_TYPE_TEXT)) &&
-		 (straight_ct = TRUE)) ||
-		(mime_part->detected_type &&
-		 strcmp (mime_part->detected_type, "text") == 0)) {
+	if ((mime_part->ct && (mime_part->ct->flags & RSPAMD_CONTENT_TYPE_TEXT)) ||
+		(mime_part->detected_type && strcmp (mime_part->detected_type, "text") == 0)) {
+
 		found_txt = TRUE;
 
 		html_tok.begin = "html";
@@ -795,16 +794,16 @@ rspamd_message_process_text_part_maybe (struct rspamd_task *task,
 
 		if (rspamd_ftok_casecmp (&mime_part->ct->subtype, &html_tok) == 0 ||
 			rspamd_ftok_casecmp (&mime_part->ct->subtype, &xhtml_tok) == 0 ||
-			(mime_part->detected_ct &&
-				rspamd_ftok_casecmp (&mime_part->detected_ct->subtype, &html_tok) == 0)) {
+			(mime_part->detected_ext &&
+				strcmp (mime_part->detected_ext, "html") == 0)) {
 			found_html = TRUE;
 		}
 	}
 
 	/* Skip attachments */
 	if ((found_txt || found_html) &&
-			mime_part->cd && mime_part->cd->type == RSPAMD_CT_ATTACHMENT &&
-			(!straight_ct || (task->cfg && !task->cfg->check_text_attachements))) {
+			(mime_part->cd && mime_part->cd->type == RSPAMD_CT_ATTACHMENT) &&
+			(!task->cfg->check_text_attachements)) {
 		debug_task ("skip attachments for checking as text parts");
 		return FALSE;
 	}


More information about the Commits mailing list