summaryrefslogtreecommitdiffstats
path: root/src/plugins/regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-04-23 17:32:44 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-04-23 17:32:44 +0400
commite956b46665a3176eeae4f8793f6e62ef73339c17 (patch)
tree7b2c5d606f7f351c605ad8d4c44e047787342a66 /src/plugins/regexp.c
parent926925fa66e6e3e7747c00997c1f8f285ebb326d (diff)
downloadrspamd-e956b46665a3176eeae4f8793f6e62ef73339c17.tar.gz
rspamd-e956b46665a3176eeae4f8793f6e62ef73339c17.zip
* Another fix to regexps parser
Diffstat (limited to 'src/plugins/regexp.c')
-rw-r--r--src/plugins/regexp.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 3acfddc5b..340e09964 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -94,6 +94,7 @@ read_regexp_expression (memory_pool_t *pool, struct regexp_module_item *chain, c
msg_warn ("read_regexp_expression: cannot parse regexp, skip expression %s = \"%s\"", symbol, line);
return FALSE;
}
+ cur->type = EXPR_REGEXP_PARSED;
}
cur = cur->next;
}
@@ -336,10 +337,10 @@ process_regexp_expression (struct expression *expr, struct worker_task *task)
stack = g_queue_new ();
while (it) {
- if (it->type == EXPR_REGEXP) {
+ if (it->type == EXPR_REGEXP_PARSED) {
/* Find corresponding symbol */
cur = process_regexp ((struct rspamd_regexp *)it->content.operand, task);
- msg_debug ("process_regexp_item: regexp %s found", cur ? "is" : "is not");
+ msg_debug ("process_regexp_expression: regexp %s found", cur ? "is" : "is not");
if (try_optimize) {
try_optimize = optimize_regexp_expression (&it, stack, cur);
} else {
@@ -348,13 +349,23 @@ process_regexp_expression (struct expression *expr, struct worker_task *task)
} else if (it->type == EXPR_FUNCTION) {
cur = (gsize)call_expression_function ((struct expression_function *)it->content.operand, task);
- msg_debug ("process_regexp_item: function %s returned %s", ((struct expression_function *)it->content.operand)->name,
+ msg_debug ("process_regexp_expression: function %s returned %s", ((struct expression_function *)it->content.operand)->name,
cur ? "true" : "false");
if (try_optimize) {
try_optimize = optimize_regexp_expression (&it, stack, cur);
} else {
g_queue_push_head (stack, GSIZE_TO_POINTER (cur));
}
+ } else if (it->type == EXPR_REGEXP) {
+ /* Compile regexp if it is not parsed */
+ it->content.operand = parse_regexp (task->task_pool, it->content.operand, task->cfg->raw_mode);
+ if (it->content.operand == NULL) {
+ msg_warn ("process_regexp_expression: cannot parse regexp, skip expression");
+ return FALSE;
+ }
+ it->type = EXPR_REGEXP_PARSED;
+ /* Continue with this regexp once again */
+ continue;
} else if (it->type == EXPR_OPERATION) {
if (g_queue_is_empty (stack)) {
/* Queue has no operands for operation, exiting */