|
|
@ -1215,11 +1215,13 @@ rspamd_rcl_statfile_handler(rspamd_mempool_t *pool, const ucl_object_t *obj, |
|
|
strlen(st->symbol), "spam", 4) != -1) { |
|
|
strlen(st->symbol), "spam", 4) != -1) { |
|
|
st->is_spam = TRUE; |
|
|
st->is_spam = TRUE; |
|
|
st->class_name = rspamd_mempool_strdup(pool, "spam"); |
|
|
st->class_name = rspamd_mempool_strdup(pool, "spam"); |
|
|
|
|
|
st->is_spam_converted = TRUE; |
|
|
} |
|
|
} |
|
|
else if (rspamd_substring_search_caseless(st->symbol, |
|
|
else if (rspamd_substring_search_caseless(st->symbol, |
|
|
strlen(st->symbol), "ham", 3) != -1) { |
|
|
strlen(st->symbol), "ham", 3) != -1) { |
|
|
st->is_spam = FALSE; |
|
|
st->is_spam = FALSE; |
|
|
st->class_name = rspamd_mempool_strdup(pool, "ham"); |
|
|
st->class_name = rspamd_mempool_strdup(pool, "ham"); |
|
|
|
|
|
st->is_spam_converted = TRUE; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
g_set_error(err, |
|
|
g_set_error(err, |
|
|
@ -1242,6 +1244,7 @@ rspamd_rcl_statfile_handler(rspamd_mempool_t *pool, const ucl_object_t *obj, |
|
|
else { |
|
|
else { |
|
|
st->class_name = rspamd_mempool_strdup(pool, "ham"); |
|
|
st->class_name = rspamd_mempool_strdup(pool, "ham"); |
|
|
} |
|
|
} |
|
|
|
|
|
st->is_spam_converted = TRUE; |
|
|
} |
|
|
} |
|
|
/* If class field is present, it was already parsed by the default parser */ |
|
|
/* If class field is present, it was already parsed by the default parser */ |
|
|
return TRUE; |
|
|
return TRUE; |
|
|
@ -1439,11 +1442,39 @@ rspamd_rcl_classifier_handler(rspamd_mempool_t *pool, |
|
|
|
|
|
|
|
|
cfg->classifiers = g_list_prepend(cfg->classifiers, ccf); |
|
|
cfg->classifiers = g_list_prepend(cfg->classifiers, ccf); |
|
|
|
|
|
|
|
|
/* Populate class_names array from statfiles */ |
|
|
|
|
|
|
|
|
/* Populate class_names array from statfiles - only for explicit multiclass configs */ |
|
|
if (ccf->statfiles) { |
|
|
if (ccf->statfiles) { |
|
|
GList *cur = ccf->statfiles; |
|
|
GList *cur = ccf->statfiles; |
|
|
|
|
|
gboolean has_explicit_classes = FALSE; |
|
|
|
|
|
|
|
|
|
|
|
/* Check if any statfile uses explicit class declaration (not converted from is_spam) */ |
|
|
|
|
|
cur = ccf->statfiles; |
|
|
|
|
|
while (cur) { |
|
|
|
|
|
struct rspamd_statfile_config *stcf = (struct rspamd_statfile_config *) cur->data; |
|
|
|
|
|
msg_debug("checking statfile %s: class_name=%s, is_spam_converted=%s", |
|
|
|
|
|
stcf->symbol, stcf->class_name ? stcf->class_name : "NULL", |
|
|
|
|
|
stcf->is_spam_converted ? "true" : "false"); |
|
|
|
|
|
if (stcf->class_name && !stcf->is_spam_converted) { |
|
|
|
|
|
has_explicit_classes = TRUE; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
cur = g_list_next(cur); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
msg_debug("has_explicit_classes = %s", has_explicit_classes ? "true" : "false"); |
|
|
|
|
|
|
|
|
|
|
|
/* Only populate class_names for explicit multiclass configurations */ |
|
|
|
|
|
if (has_explicit_classes) { |
|
|
|
|
|
msg_debug("populating class_names for multiclass configuration"); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
msg_debug("skipping class_names population for binary configuration"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (has_explicit_classes) { |
|
|
ccf->class_names = g_ptr_array_new(); |
|
|
ccf->class_names = g_ptr_array_new(); |
|
|
|
|
|
|
|
|
|
|
|
cur = ccf->statfiles; |
|
|
while (cur) { |
|
|
while (cur) { |
|
|
struct rspamd_statfile_config *stcf = (struct rspamd_statfile_config *) cur->data; |
|
|
struct rspamd_statfile_config *stcf = (struct rspamd_statfile_config *) cur->data; |
|
|
if (stcf->class_name) { |
|
|
if (stcf->class_name) { |
|
|
@ -1466,6 +1497,7 @@ rspamd_rcl_classifier_handler(rspamd_mempool_t *pool, |
|
|
cur = g_list_next(cur); |
|
|
cur = g_list_next(cur); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return TRUE; |
|
|
return TRUE; |
|
|
} |
|
|
} |
|
|
|