From: Vsevolod Stakhov Date: Thu, 23 Apr 2009 12:56:43 +0000 (+0400) Subject: * Fix regexp_match_number function X-Git-Tag: 0.2.7~181 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=926925fa66e6e3e7747c00997c1f8f285ebb326d;p=rspamd.git * Fix regexp_match_number function --- diff --git a/src/expressions.c b/src/expressions.c index c115ad85c..98a21bf81 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -731,8 +731,9 @@ get_function_arg (struct expression *expr, struct worker_task *task, gboolean wa while (it) { if (it->type == EXPR_REGEXP || it->type == EXPR_STR) { g_queue_free (stack); - msg_warn ("get_function_arg: cannot parse function arguments that contains regexps or strings"); - return NULL; + res->type = EXPRESSION_ARGUMENT_EXPR; + res->data = expr; + return res; } else if (it->type == EXPR_FUNCTION) { cur = (gsize)call_expression_function ((struct expression_function *)it->content.operand, task); msg_debug ("get_function_arg: function %s returned %s", ((struct expression_function *)it->content.operand)->name, diff --git a/src/expressions.h b/src/expressions.h index 5debe87b2..9d80587b4 100644 --- a/src/expressions.h +++ b/src/expressions.h @@ -25,6 +25,7 @@ struct expression_argument { enum { EXPRESSION_ARGUMENT_NORMAL, EXPRESSION_ARGUMENT_BOOL, + EXPRESSION_ARGUMENT_EXPR, } type; /**< type of argument (text or other function) */ void *data; /**< pointer to its data */ }; diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 4de5984c9..3acfddc5b 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -421,9 +421,7 @@ regexp_common_filter (struct worker_task *task) static gboolean rspamd_regexp_match_number (struct worker_task *task, GList *args) { - char *param_pattern; int param_count, res = 0; - struct rspamd_regexp *re; struct expression_argument *arg; GList *cur; @@ -444,21 +442,6 @@ rspamd_regexp_match_number (struct worker_task *task, GList *args) } } else { - param_pattern = (char *)arg->data; - if (*param_pattern != '/') { - /* Skip non-regexp arguments */ - cur = g_list_next (cur); - continue; - } - /* This is regexp, so compile and create g_regexp object */ - if ((re = re_cache_check (param_pattern)) == NULL) { - re = parse_regexp (task->task_pool, param_pattern, task->cfg->raw_mode); - if (re == NULL) { - msg_warn ("rspamd_regexp_match_number: cannot compile regexp for function"); - return FALSE; - } - re_cache_add (param_pattern, re); - } if (process_regexp_expression (cur->data, task)) { res ++; }