From c967577fbd835bc1db05907aa754acdd56a4f6aa Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 12 Nov 2016 13:27:25 +0000 Subject: [PATCH] [Feature] Support multiple hashes in delhash path --- src/plugins/fuzzy_check.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index f1e5b0602..803958b81 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -2429,26 +2429,33 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent, res = 0; if (is_hash) { + GPtrArray *args; const rspamd_ftok_t *arg; + guint i; - arg = rspamd_http_message_find_header (msg, "Hash"); + args = rspamd_http_message_find_header_multiple (msg, "Hash"); - if (arg) { + if (args) { struct fuzzy_cmd_io *io; + commands = g_ptr_array_sized_new (args->len); - io = fuzzy_cmd_hash (rule, cmd, arg, flag, value, - task->task_pool); + for (i = 0; i < args->len; i ++) { + arg = g_ptr_array_index (args, i); + io = fuzzy_cmd_hash (rule, cmd, arg, flag, value, + task->task_pool); - if (io) { - commands = g_ptr_array_sized_new (1); - g_ptr_array_add (commands, io); - res = register_fuzzy_controller_call (conn_ent, - rule, - task, - commands, - saved, - err); + if (io) { + g_ptr_array_add (commands, io); + } } + + res = register_fuzzy_controller_call (conn_ent, + rule, + task, + commands, + saved, + err); + g_ptr_array_free (args, TRUE); } else { rspamd_controller_send_error (conn_ent, 400, -- 2.39.5