peilaus alkaen
https://github.com/rspamd/rspamd.git
synced 2024-08-24 05:54:36 +02:00
* Threat raw header regexps as raw regexps
* Add regexp flag /r for raw regexp of any types
This commit is contained in:
vanhempi
d50dff03fd
commit
83f0dbe021
@ -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;
|
||||
|
Ladataan…
Viittaa uudesa ongelmassa
Block a user