commit ae698ea: [Minor] Fuzzy_check: Do not penalise score for large images

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Mar 12 11:42:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-03-12 11:36:01 +0000
URL: https://github.com/rspamd/rspamd/commit/ae698ea973b832bffa5aa3c98fddcf29031073f2 (HEAD -> master)

[Minor] Fuzzy_check: Do not penalise score for large images

---
 src/plugins/fuzzy_check.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 672a6dc63..a0e4df012 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -1875,6 +1875,8 @@ fuzzy_insert_result (struct fuzzy_client_session *session,
 	struct fuzzy_client_result *res;
 	gboolean is_fuzzy = FALSE;
 	gchar hexbuf[rspamd_cryptobox_HASHBYTES * 2 + 1];
+	/* Discriminate scores for small images */
+	static const guint short_image_limit = 32 * 1024;
 
 	/* Get mapping by flag */
 	if ((map =
@@ -1902,7 +1904,10 @@ fuzzy_insert_result (struct fuzzy_client_session *session,
 	nval = fuzzy_normalize (rep->v1.value, weight);
 
 	if (io && (io->flags & FUZZY_CMD_FLAG_IMAGE)) {
-		nval *= rspamd_normalize_probability (rep->v1.prob, 0.5);
+		if (!io->part || io->part->parsed_data.len <= short_image_limit) {
+			nval *= rspamd_normalize_probability (rep->v1.prob, 0.5);
+		}
+
 		type = "img";
 		res->type = FUZZY_RESULT_IMG;
 	}


More information about the Commits mailing list