diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-04-16 17:13:37 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-04-16 17:13:37 +0400 |
commit | 83f0dbe021888839dbcc3b3d6dff48b8da21cffb (patch) | |
tree | 5705532f9d86fe11ded03b332dd224c8e05127ab /src | |
parent | d50dff03fdf56db4a24cf44e4e9eec70c69e81c3 (diff) | |
download | rspamd-83f0dbe021888839dbcc3b3d6dff48b8da21cffb.tar.gz rspamd-83f0dbe021888839dbcc3b3d6dff48b8da21cffb.zip |
* Threat raw header regexps as raw regexps
* Add regexp flag /r for raw regexp of any types
Diffstat (limited to 'src')
-rw-r--r-- | src/expressions.c | 13 | ||||
-rw-r--r-- | src/plugins/regexp.c | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/expressions.c b/src/expressions.c index 085708342..6519879c5 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -575,6 +575,10 @@ parse_regexp (memory_pool_t *pool, char *line) regexp_flags |= G_REGEX_OPTIMIZE; p ++; break; + case 'r': + regexp_flags |= G_REGEX_RAW; + p ++; + break; /* Type flags */ case 'H': if (result->type == REGEXP_NONE) { @@ -638,8 +642,13 @@ parse_regexp (memory_pool_t *pool, char *line) msg_warn ("parse_regexp: could not read regexp: %s while reading regexp %s", err->message, src); return NULL; } - result->raw_regexp = g_regex_new (begin, regexp_flags | G_REGEX_RAW, 0, &err); - memory_pool_add_destructor (pool, (pool_destruct_func)g_regex_unref, (void *)result->raw_regexp); + if ((regexp_flags & G_REGEX_RAW) != 0) { + result->raw_regexp = result->regexp; + } + else { + result->raw_regexp = g_regex_new (begin, regexp_flags | G_REGEX_RAW, 0, &err); + memory_pool_add_destructor (pool, (pool_destruct_func)g_regex_unref, (void *)result->raw_regexp); + } *end = '/'; if (result->raw_regexp == NULL || err != NULL) { diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index fa9eafdd4..f057b29c2 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -279,7 +279,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task) /* Temporary null terminate this part of string */ t = *c; *c = '\0'; - if (g_regex_match (re->regexp, headerv, 0, NULL) == TRUE) { + if (g_regex_match (re->raw_regexp, headerv, 0, NULL) == TRUE) { *c = t; task_cache_add (task, re, 1); return 1; |