diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-25 11:20:40 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-25 11:20:40 +0100 |
commit | 747afaaa805f90d58b4330eb32119480fe40d3db (patch) | |
tree | 723ea52e15cdeffd94698762142e7d6417763740 /src/libmime/lang_detection.c | |
parent | c361d4c3ec2dd6499bc6c4da4790376074d8779a (diff) | |
download | rspamd-747afaaa805f90d58b4330eb32119480fe40d3db.tar.gz rspamd-747afaaa805f90d58b4330eb32119480fe40d3db.zip |
[Feature] Langdet: Limit number of stop words to be checked
Diffstat (limited to 'src/libmime/lang_detection.c')
-rw-r--r-- | src/libmime/lang_detection.c | 5 |
1 files changed, 5 insertions, 0 deletions
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; |