From: Vsevolod Stakhov Date: Thu, 25 Jul 2019 10:20:40 +0000 (+0100) Subject: [Feature] Langdet: Limit number of stop words to be checked X-Git-Tag: 2.0~496 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=747afaaa805f90d58b4330eb32119480fe40d3db;p=rspamd.git [Feature] Langdet: Limit number of stop words to be checked --- diff --git a/src/libmime/lang_detection.c b/src/libmime/lang_detection.c index 7096da585..0f1563d69 100644 --- a/src/libmime/lang_detection.c +++ b/src/libmime/lang_detection.c @@ -1590,6 +1590,7 @@ rspamd_language_detector_sw_cb (struct rspamd_multipattern *mp, struct rspamd_stop_word_range *r; struct rspamd_sw_cbdata *cbdata = (struct rspamd_sw_cbdata *)context; khiter_t k; + static const gsize max_stop_words = 80; if (match_start > 0) { prev = text + match_start - 1; @@ -1616,6 +1617,10 @@ rspamd_language_detector_sw_cb (struct rspamd_multipattern *mp, if (k != kh_end (cbdata->res)) { kh_value (cbdata->res, k) ++; + + if (kh_value (cbdata->res, k) > max_stop_words) { + return 1; + } } else { gint tt;