]> source.dussan.org Git - rspamd.git/commitdiff
* Fix regexp_match_number function
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 23 Apr 2009 12:56:43 +0000 (16:56 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 23 Apr 2009 12:56:43 +0000 (16:56 +0400)
src/expressions.c
src/expressions.h
src/plugins/regexp.c

index c115ad85ca97c2e09e4a67a2a9121f281a2e36f4..98a21bf81f62608ce7abc0c3961f014c0e51f111 100644 (file)
@@ -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,
index 5debe87b2237cfaf3c6ac38a4fa0a02291a6ce5f..9d80587b4a5e055c189bfa52801e85e4e953d9a5 100644 (file)
@@ -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                                                        */
 };
index 4de5984c9ef57376418893cf7f3eb6584dfb4edd..3acfddc5b8538f49e2be0d79a12d59f496f7cc9f 100644 (file)
@@ -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 ++;
                        }