diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-24 19:47:10 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-24 19:47:10 +0300 |
commit | 56033466857544978d09dc4afa53c2eb359e8ea5 (patch) | |
tree | 50e27baad50b5c44ed2bb7d1ac54f84ed02174f7 /src | |
parent | 474a08d028bce4263a8a919fc7d5d705cd1daa45 (diff) | |
download | rspamd-56033466857544978d09dc4afa53c2eb359e8ea5.tar.gz rspamd-56033466857544978d09dc4afa53c2eb359e8ea5.zip |
* Fix bug in expressions parser and optimizer
Diffstat (limited to 'src')
-rw-r--r-- | src/expressions.c | 5 | ||||
-rw-r--r-- | src/plugins/regexp.c | 5 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/expressions.c b/src/expressions.c index f222ea2b4..b115eba72 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -342,16 +342,13 @@ parse_expression (memory_pool_t *pool, char *line) break; case READ_FUNCTION: - if (func == NULL) { - func = memory_pool_alloc (pool, sizeof (struct expression_function)); - } - if (*p == '/') { /* In fact it is regexp */ state = READ_REGEXP; c ++; p ++; } else if (*p == '(') { + func = memory_pool_alloc (pool, sizeof (struct expression_function)); func->name = memory_pool_alloc (pool, p - c + 1); func->args = NULL; g_strlcpy (func->name, c, (p - c + 1)); diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 53c64d2b3..e9c4ca7bf 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -268,13 +268,13 @@ static gboolean optimize_regexp_expression (struct expression **e, GQueue *stack, gboolean res) { struct expression *it = *e; - gboolean ret = FALSE; + gboolean ret = FALSE, is_nearest = TRUE; while (it) { /* Find first operation for this iterator */ if (it->type == EXPR_OPERATION) { /* If this operation is just ! just inverse res and check for further operators */ - if (it->content.operation == '!') { + if (it->content.operation == '!' && is_nearest) { res = !res; it = it->next; *e = it; @@ -290,6 +290,7 @@ optimize_regexp_expression (struct expression **e, GQueue *stack, gboolean res) } break; } + is_nearest = FALSE; it = it->next; } |