* Threat raw header regexps as raw regexps

* Add regexp flag /r for raw regexp of any types
Этот коммит содержится в:
Vsevolod Stakhov 2009-04-16 17:13:37 +04:00
родитель d50dff03fd
Коммит 83f0dbe021
3 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -101,6 +101,7 @@ headername=/pattern/flags
если регэксп ищет соответствие хедера и выражения
Флаги регэскпов:
i, m, s, x, u, o - такие же, как у perl/pcre
r - "сырой" незакодированный в utf8 regexp
H - ищет по заголовкам
M - ищет по всему сообщению (в "сыром" виде)
P - ищет по всем mime частям

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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;