commit 8939b05: [Fix] Core: Fix parts distance calculations

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Dec 27 18:28:07 UTC 2018


Author: Vsevolod Stakhov
Date: 2018-12-13 15:45:00 +0000
URL: https://github.com/rspamd/rspamd/commit/8939b059fbe42e5386e7c05b42212c83da9a2c1f

[Fix] Core: Fix parts distance calculations

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

diff --git a/src/libmime/message.c b/src/libmime/message.c
index bbae5e426..63494202d 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -1222,6 +1222,23 @@ rspamd_message_process (struct rspamd_task *task)
 	rspamd_images_process (task);
 	rspamd_archives_process (task);
 
+	/* Calculate average words length and number of short words */
+	struct rspamd_mime_text_part *text_part;
+	gdouble *var;
+	guint total_words = 0;
+
+	PTR_ARRAY_FOREACH (task->text_parts, i, text_part) {
+		if (!text_part->language) {
+			rspamd_mime_part_detect_language (task, text_part);
+		}
+
+		rspamd_mime_part_extract_words (task, text_part);
+
+		if (text_part->utf_words) {
+			total_words += text_part->nwords;
+		}
+	}
+
 	/* Calculate distance for 2-parts messages */
 	if (task->text_parts->len == 2) {
 		p1 = g_ptr_array_index (task->text_parts, 0);
@@ -1311,23 +1328,6 @@ rspamd_message_process (struct rspamd_task *task)
 		}
 	}
 
-	/* Calculate average words length and number of short words */
-	struct rspamd_mime_text_part *text_part;
-	gdouble *var;
-	guint total_words = 0;
-
-	PTR_ARRAY_FOREACH (task->text_parts, i, text_part) {
-		if (!text_part->language) {
-			rspamd_mime_part_detect_language (task, text_part);
-		}
-
-		rspamd_mime_part_extract_words (task, text_part);
-
-		if (text_part->utf_words) {
-			total_words += text_part->nwords;
-		}
-	}
-
 	if (total_words > 0) {
 		var = rspamd_mempool_get_variable (task->task_pool,
 				RSPAMD_MEMPOOL_AVG_WORDS_LEN);


More information about the Commits mailing list