diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-06 09:28:10 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-06 09:28:10 +0100 |
commit | ab08ab2a0b3f27022c3552ddb5c3b9e0ae901a01 (patch) | |
tree | d1b6fc80fc3fe0b7c6c278903e55f264691943fd | |
parent | 9a3b5ef566ad7c57b6509511e53f9dbe58340268 (diff) | |
download | rspamd-ab08ab2a0b3f27022c3552ddb5c3b9e0ae901a01.tar.gz rspamd-ab08ab2a0b3f27022c3552ddb5c3b9e0ae901a01.zip |
[Minor] Fix CMA calculations
-rw-r--r-- | src/libmime/message.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c index 39768e0e0..a5dec9775 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -109,7 +109,7 @@ rspamd_mime_part_extract_words (struct rspamd_task *task, #endif if (w->len > 0 && (w->flags & RSPAMD_STAT_TOKEN_FLAG_TEXT)) { - avg_len = avg_len + (w->len - avg_len) / (double) i; + avg_len = avg_len + (w->len - avg_len) / (double) (i + 1); if (r != NULL) { nlen = strlen (r); @@ -119,19 +119,22 @@ rspamd_mime_part_extract_words (struct rspamd_task *task, if (IS_PART_UTF (part)) { rspamd_str_lc_utf8 (temp_word, nlen); - } else { + } + else { rspamd_str_lc (temp_word, nlen); } w->begin = temp_word; w->len = nlen; - } else { + } + else { temp_word = rspamd_mempool_alloc (task->task_pool, w->len); memcpy (temp_word, w->begin, w->len); if (IS_PART_UTF (part)) { rspamd_str_lc_utf8 (temp_word, w->len); - } else { + } + else { rspamd_str_lc (temp_word, w->len); } @@ -168,7 +171,8 @@ rspamd_mime_part_extract_words (struct rspamd_task *task, *avg_len_p = total_len; rspamd_mempool_set_variable (task->task_pool, RSPAMD_MEMPOOL_AVG_WORDS_LEN, avg_len_p, NULL); - } else { + } + else { *avg_len_p += total_len; } @@ -181,7 +185,8 @@ rspamd_mime_part_extract_words (struct rspamd_task *task, *short_len_p = short_len; rspamd_mempool_set_variable (task->task_pool, RSPAMD_MEMPOOL_SHORT_WORDS_CNT, avg_len_p, NULL); - } else { + } + else { *short_len_p += short_len; } } |