commit 3975d4e: [Minor] Do not use text heuristic when checking attachments

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Oct 7 20:21:06 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-10-07 20:23:54 +0100
URL: https://github.com/rspamd/rspamd/commit/3975d4e8177b0afe941ddff7472a02dacfd08627

[Minor] Do not use text heuristic when checking attachments

---
 src/libmime/message.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/libmime/message.c b/src/libmime/message.c
index 8209626b4..a450f67fe 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -813,11 +813,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;
+	gboolean found_html = FALSE, found_txt = FALSE, straight_ct = FALSE;
 	enum rspamd_action_type act;
 
-	if (IS_CT_TEXT (mime_part->ct) || (mime_part->detected_type &&
-									   strcmp (mime_part->detected_type, "text") == 0)) {
+	if ((IS_CT_TEXT (mime_part->ct) && (straight_ct = TRUE)) ||
+					(mime_part->detected_type &&
+						strcmp (mime_part->detected_type, "text") == 0)) {
 		found_txt = TRUE;
 
 		html_tok.begin = "html";
@@ -836,9 +837,9 @@ rspamd_message_process_text_part_maybe (struct rspamd_task *task,
 	/* Skip attachments */
 	if ((found_txt || found_html) &&
 			mime_part->cd && mime_part->cd->type == RSPAMD_CT_ATTACHMENT &&
-			(task->cfg && !task->cfg->check_text_attachements)) {
+			(!straight_ct || (task->cfg && !task->cfg->check_text_attachements))) {
 		debug_task ("skip attachments for checking as text parts");
-		return TRUE;
+		return FALSE;
 	}
 	else if (!(found_txt || found_html)) {
 		/* Not a text part */


More information about the Commits mailing list