diff options
author | cebka@lenovo-laptop <cebka@lenovo-laptop> | 2010-02-01 19:07:33 +0300 |
---|---|---|
committer | cebka@lenovo-laptop <cebka@lenovo-laptop> | 2010-02-01 19:07:33 +0300 |
commit | 18b4a627676f71b37c98f566218fad6a249025cb (patch) | |
tree | 389153db1066311040184f2b908e4f3b7b5e8536 /src/controller.c | |
parent | 56f520e21f7f164bcd2d99bb46b5875b0a398e75 (diff) | |
download | rspamd-18b4a627676f71b37c98f566218fad6a249025cb.tar.gz rspamd-18b4a627676f71b37c98f566218fad6a249025cb.zip |
* Add ability to classify only specific headers (for example Subject)
Diffstat (limited to 'src/controller.c')
-rw-r--r-- | src/controller.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/controller.c b/src/controller.c index b0aeca65a..4e4b44cb3 100644 --- a/src/controller.c +++ b/src/controller.c @@ -651,16 +651,29 @@ controller_read_socket (f_str_t * in, void *arg) rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE); return FALSE; } - cur = g_list_first (task->text_parts); + if ((s = g_hash_table_lookup (session->learn_classifier->opts, "header")) != NULL) { + cur = message_get_header (task->task_pool, task->message, s); + if (cur) { + memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_list_free, cur); + } + } + else { + cur = g_list_first (task->text_parts); + } while (cur) { - part = cur->data; - if (part->is_empty) { - cur = g_list_next (cur); - continue; + if (s != NULL) { + c.len = strlen (cur->data); + c.begin = cur->data; + } + else { + part = cur->data; + if (part->is_empty) { + cur = g_list_next (cur); + continue; + } + c.begin = part->content->data; + c.len = part->content->len; } - c.begin = part->content->data; - c.len = part->content->len; - if (!session->learn_classifier->tokenizer->tokenize_func (session->learn_classifier->tokenizer, session->session_pool, &c, &tokens)) { i = snprintf (out_buf, sizeof (out_buf), "learn fail, tokenizer error" CRLF); free_task (task, FALSE); |