]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Distinguish explicit multi-class from legacy binary configs
authorAlexander Moisseev <moiseev@mezonplus.ru>
Tue, 17 Feb 2026 13:13:48 +0000 (16:13 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Tue, 17 Feb 2026 13:13:48 +0000 (16:13 +0300)
Check is_spam_converted flag to differentiate between:
- Explicit class declaration (new format) -> multi-class
- Converted is_spam=true/false (legacy) -> binary

This fixes incorrect "binary" detection for explicit multi-class
configurations using class="spam" and class="ham".

src/libstat/stat_process.c

index 379e918ac200b3cd34d803d7185cf51116467112..b16137f0298e76f1bd4703f696808ebad7095ef7 100644 (file)
@@ -1766,6 +1766,7 @@ rspamd_classifier_type(const struct rspamd_classifier_config *cfg)
        gboolean has_spam = FALSE;
        gboolean has_ham = FALSE;
        gboolean has_other = FALSE;
+       gboolean has_explicit_classes = FALSE;
        GList *cur;
 
        if (cfg == NULL) {
@@ -1780,6 +1781,10 @@ rspamd_classifier_type(const struct rspamd_classifier_config *cfg)
                        continue;
                }
 
+               if (!stcf->is_spam_converted) {
+                       has_explicit_classes = TRUE;
+               }
+
                if (g_ascii_strcasecmp(stcf->class_name, "spam") == 0) {
                        has_spam = TRUE;
                }
@@ -1791,6 +1796,12 @@ rspamd_classifier_type(const struct rspamd_classifier_config *cfg)
                }
        }
 
+       /* If any statfile has explicit class (not converted from is_spam) */
+       if (has_explicit_classes) {
+               return "multi-class";
+       }
+
+       /* Legacy binary: spam=true/false converted to class names */
        if (has_spam && has_ham && !has_other) {
                return "binary";
        }