case 's':
case 'u':
case 'o':
+ case 'r':
case 'H':
case 'M':
case 'P':
if (line == NULL || pool == NULL) {
return NULL;
}
+
+ msg_debug ("parse_expression: parsing expression {{ %s }}", line);
function_stack = g_queue_new ();
p = line;
case READ_REGEXP_FLAGS:
if (!is_regexp_flag (*p) || *(p + 1) == '\0') {
if (c != p) {
- /* Copy operand */
- if (*(p + 1) == '\0' || *(p - 1) == '/') {
- p++;
+ if (is_regexp_flag (*p) && *(p + 1) == '\0') {
+ p ++;
}
- str = memory_pool_alloc (pool, p - c + 1);
- g_strlcpy (str, c - 1, (p - c + 1));
+ str = memory_pool_alloc (pool, p - c + 2);
+ g_strlcpy (str, c - 1, (p - c + 2));
g_strstrip (str);
+ msg_debug ("parse_expression: found regexp: %s", str);
if (strlen (str) > 0) {
insert_expression (pool, &expr, EXPR_REGEXP, 0, str);
}
GRegex *regexp;
struct uri *url;
int r;
+
if (re == NULL) {
msg_info ("process_regexp: invalid regexp passed");
}
if ((r = task_cache_check (task, re)) != -1) {
+ msg_debug ("process_regexp: regexp /%s/ is found in cache, result: %d", re->regexp_text, r);
return r == 1;
}
switch (re->type) {
case REGEXP_NONE:
+ msg_warn ("process_regexp: bad error detected: /%s/ has invalid regexp type", re->regexp_text);
return 0;
case REGEXP_HEADER:
if (re->header == NULL) {
*c = t;
task_cache_add (task, re, 0);
return 0;
+ default:
+ msg_warn ("process_regexp: bad error detected: %p is not a valid regexp object", re);
}
/* Not reached */
GQueue *stack;
gsize cur, op1, op2;
struct expression *it = expr;
+ struct rspamd_regexp *re;
gboolean try_optimize = TRUE;
stack = g_queue_new ();
it = it->next;
continue;
}
- it->content.operand = parse_regexp (task->cfg->cfg_pool, it->content.operand, task->cfg->raw_mode);
- if (it->content.operand == NULL) {
+ re = parse_regexp (task->cfg->cfg_pool, it->content.operand, task->cfg->raw_mode);
+ if (re == NULL) {
msg_warn ("process_regexp_expression: cannot parse regexp, skip expression");
return FALSE;
}
+ it->content.operand = re;
it->type = EXPR_REGEXP_PARSED;
/* Continue with this regexp once again */
continue;