]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fuzzy_check: Do not penalise score for large images
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Mar 2019 11:36:01 +0000 (11:36 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Mar 2019 11:36:01 +0000 (11:36 +0000)
src/plugins/fuzzy_check.c

index 672a6dc63a4210a9f750fb91fc264ef79f8ca609..a0e4df0123f7fe9e4869d5f3db03a2b924f6e36d 100644 (file)
@@ -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;
        }