return badness;
}
-static void
+static gboolean
rspamd_chartable_process_part (struct rspamd_task *task,
struct rspamd_mime_text_part *part,
struct chartable_ctx *chartable_module_ctx,
if (part == NULL || part->utf_words == NULL ||
part->utf_words->len == 0) {
- return;
+ return FALSE;
}
for (i = 0; i < part->utf_words->len; i++) {
cur_score /= (gdouble)part->nwords;
- if (cur_score > 2.0) {
- cur_score = 2.0;
+ if (cur_score > 1.0) {
+ cur_score = 1.0;
}
if (cur_score > chartable_module_ctx->threshold) {
rspamd_task_insert_result (task, chartable_module_ctx->symbol,
cur_score, NULL);
-
+ return TRUE;
}
+
+ return FALSE;
}
static void
struct rspamd_mime_text_part *part;
struct chartable_ctx *chartable_module_ctx = chartable_get_context (task->cfg);
const gchar *language = NULL;
- gboolean ignore_diacritics = FALSE;
+ gboolean ignore_diacritics = FALSE, seen_violated_part = FALSE;
+ /* Check if we have parts with diacritic symbols language */
PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, part) {
if (part->languages && part->languages->len > 0) {
struct rspamd_lang_detector_res *lang =
}
}
- rspamd_chartable_process_part (task, part, chartable_module_ctx,
- ignore_diacritics);
+ if (rspamd_chartable_process_part (task, part, chartable_module_ctx,
+ ignore_diacritics)) {
+ seen_violated_part = TRUE;
+ }
+ }
+
+ if (MESSAGE_FIELD (task, text_parts)->len == 0) {
+ /* No text parts, assume that we should ignore diacritics checks for metatokens */
+ ignore_diacritics = TRUE;
}
if (task->meta_words != NULL) {
cur_score /= (gdouble)arlen;
- if (cur_score > 2.0) {
- cur_score = 2.0;
+ if (cur_score > 1.0) {
+ cur_score = 1.0;
}
if (cur_score > chartable_module_ctx->threshold) {
+ if (!seen_violated_part) {
+ /* Further penalise */
+ if (cur_score > 0.25) {
+ cur_score = 0.25;
+ }
+ }
+
rspamd_task_insert_result (task, chartable_module_ctx->symbol,
cur_score, "subject");