]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Treat '__' symbols as ghost symbols.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Feb 2015 13:40:29 +0000 (13:40 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Feb 2015 13:40:29 +0000 (13:40 +0000)
src/libserver/symbols_cache.c
src/plugins/lua/spamassassin.lua

index 0ecd6e6e855fd25429fc11eb69eea4fe662a1701..248372d2920101f87f2194627e6d66cad5d81ed2 100644 (file)
@@ -366,7 +366,7 @@ register_symbol_common (struct symbols_cache **cache,
 
        /* Check whether this item is skipped */
        skipped = !ghost;
-       if (!item->is_callback && pcache->cfg &&
+       if (!ghost && !item->is_callback && pcache->cfg &&
                        g_hash_table_lookup (pcache->cfg->metrics_symbols, name) == NULL) {
                cur = g_list_first (pcache->cfg->metrics_list);
                while (cur) {
index 03387255b852cb0e400c9ac8c0dc73b74130bc45..bb96fb2e8c377231aa66a6e908804ef8f0841525 100644 (file)
@@ -132,6 +132,14 @@ end
 
 -- Now check all valid rules and add the according rspamd rules
 
+local function calculate_score(sym)
+  if _.all(function(c) return c == '_' end, _.take_n(2, _.iter(sym))) then
+    return 0.0
+  end
+
+  return 1.0
+end
+
 -- Meta rules
 _.each(function(k, r)
     rspamd_config:add_composite(k, r['meta'])
@@ -158,7 +166,7 @@ _.each(function(k, r)
         end
       end
     end
-    rspamd_config:register_symbol(k, 1.0, f)
+    rspamd_config:register_symbol(k, calculate_score(k), f)
     if r['score'] then
       rspamd_config:set_metric_symbol(k, r['score'], r['description'])
     end
@@ -182,7 +190,7 @@ _.each(function(k, r)
         end
       end
     end
-    rspamd_config:register_symbol(k, 1.0, f)
+    rspamd_config:register_symbol(k, calculate_score(k), f)
     if r['score'] then
       rspamd_config:set_metric_symbol(k, r['score'], r['description'])
     end
@@ -200,7 +208,7 @@ _.each(function(k, r)
         return
       end
     end
-    rspamd_config:register_symbol(k, 1.0, f)
+    rspamd_config:register_symbol(k, calculate_score(k), f)
     if r['score'] then
       rspamd_config:set_metric_symbol(k, r['score'], r['description'])
     end