From: Vsevolod Stakhov Date: Mon, 24 Oct 2011 13:52:19 +0000 (+0300) Subject: Fix bug in compare_content_param function. X-Git-Tag: 0.4.5~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bc658b66cee9ba7184d23b195ce2f40e297034c;p=thirdparty%2Frspamd.git Fix bug in compare_content_param function. --- diff --git a/src/expressions.c b/src/expressions.c index acf1b31a2a..3012d2d5d4 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -1193,31 +1193,33 @@ rspamd_content_type_compare_param (struct worker_task * task, GList * args, void if ((param_data = g_mime_content_type_get_parameter ((GMimeContentType *)ct, param_name)) == NULL) { result = FALSE; } - if (*param_pattern == '/') { - /* This is regexp, so compile and create g_regexp object */ - if ((re = re_cache_check (param_pattern, task->cfg->cfg_pool)) == NULL) { - re = parse_regexp (task->cfg->cfg_pool, param_pattern, task->cfg->raw_mode); - if (re == NULL) { - msg_warn ("cannot compile regexp for function"); - return FALSE; + else { + if (*param_pattern == '/') { + /* This is regexp, so compile and create g_regexp object */ + if ((re = re_cache_check (param_pattern, task->cfg->cfg_pool)) == NULL) { + re = parse_regexp (task->cfg->cfg_pool, param_pattern, task->cfg->raw_mode); + if (re == NULL) { + msg_warn ("cannot compile regexp for function"); + return FALSE; + } + re_cache_add (param_pattern, re, task->cfg->cfg_pool); } - re_cache_add (param_pattern, re, task->cfg->cfg_pool); - } - if ((r = task_cache_check (task, re)) == -1) { - if (g_regex_match (re->regexp, param_data, 0, NULL) == TRUE) { - task_cache_add (task, re, 1); - return TRUE; + if ((r = task_cache_check (task, re)) == -1) { + if (g_regex_match (re->regexp, param_data, 0, NULL) == TRUE) { + task_cache_add (task, re, 1); + return TRUE; + } + task_cache_add (task, re, 0); } - task_cache_add (task, re, 0); - } - else { + else { + } } - } - else { - /* Just do strcasecmp */ - if (g_ascii_strcasecmp (param_data, param_pattern) == 0) { - return TRUE; + else { + /* Just do strcasecmp */ + if (g_ascii_strcasecmp (param_data, param_pattern) == 0) { + return TRUE; + } } } /* Get next part */