Przeglądaj źródła

* Threat raw header regexps as raw regexps

* Add regexp flag /r for raw regexp of any types
tags/0.2.7
Vsevolod Stakhov 15 lat temu
rodzic
commit
83f0dbe021
3 zmienionych plików z 13 dodań i 3 usunięć
  1. 1
    0
      README.utf8.txt
  2. 11
    2
      src/expressions.c
  3. 1
    1
      src/plugins/regexp.c

+ 1
- 0
README.utf8.txt Wyświetl plik

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

+ 11
- 2
src/expressions.c Wyświetl plik

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

+ 1
- 1
src/plugins/regexp.c Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz