]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Improve headers tokens in bayes
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 May 2018 12:34:53 +0000 (13:34 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 May 2018 12:34:53 +0000 (13:34 +0100)
src/libstat/stat_process.c

index 4f7f4e7033642e14da05ef79c4983c496a1639d2..070b9d6ca27b3f476b1bf61604379b9ed1a03cb7 100644 (file)
@@ -190,8 +190,13 @@ rspamd_stat_tokenize_parts_metadata (struct rspamd_stat_ctx *st_ctx,
                hdr = cur->data;
 
                if (hdr->name && hdr->type != RSPAMD_HEADER_RECEIVED) {
-                       elt.begin = hdr->name;
-                       elt.len = strlen (hdr->name);
+                       /* We assume that headers count is not more than 10^10 */
+                       gsize nlen = strlen (hdr->name) + 1 + 10;
+                       gchar *hdrbuf = rspamd_mempool_alloc (task->task_pool, nlen);
+                       nlen = rspamd_snprintf (hdrbuf, nlen, "%s:%d", hdr->name, hdr->order);
+                       rspamd_str_lc (hdrbuf, nlen);
+                       elt.begin = hdrbuf;
+                       elt.len = nlen;
                        g_array_append_val (ar, elt);
                }