diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-12 17:58:09 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-12 17:58:09 +0300 |
commit | 9a0362647374be48a29887d0571b8a665877be6b (patch) | |
tree | d2d5de53776d3b1b1faec6cd2254dccf31b81024 /src/cfg_utils.c | |
parent | 2003dce62438e513e614056540c22f4f755ec88b (diff) | |
download | rspamd-9a0362647374be48a29887d0571b8a665877be6b.tar.gz rspamd-9a0362647374be48a29887d0571b8a665877be6b.zip |
* Some fixes to regexp module
* Add documentation for rspamd regexp module
Diffstat (limited to 'src/cfg_utils.c')
-rw-r--r-- | src/cfg_utils.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/cfg_utils.c b/src/cfg_utils.c index 7efb9390d..3d2ce611c 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -562,6 +562,13 @@ parse_regexp (memory_pool_t *pool, char *line) GError *err = NULL; result = memory_pool_alloc0 (pool, sizeof (struct rspamd_regexp)); + /* Skip whitespaces */ + while (g_ascii_isspace (*line)) { + line ++; + } + if (line == '\0') { + return NULL; + } /* First try to find header name */ begin = strchr (line, '='); if (begin != NULL) { @@ -626,26 +633,26 @@ parse_regexp (memory_pool_t *pool, char *line) break; /* Type flags */ case 'H': - if (type != REGEXP_NONE) { - type = REGEXP_HEADER; + if (result->type == REGEXP_NONE) { + result->type = REGEXP_HEADER; } p ++; break; case 'M': - if (type != REGEXP_NONE) { - type = REGEXP_MESSAGE; + if (result->type == REGEXP_NONE) { + result->type = REGEXP_MESSAGE; } p ++; break; case 'P': - if (type != REGEXP_NONE) { - type = REGEXP_MIME; + if (result->type == REGEXP_NONE) { + result->type = REGEXP_MIME; } p ++; break; case 'U': - if (type != REGEXP_NONE) { - type = REGEXP_URL; + if (result->type == REGEXP_NONE) { + result->type = REGEXP_URL; } p ++; break; @@ -656,8 +663,6 @@ parse_regexp (memory_pool_t *pool, char *line) } } - result = memory_pool_alloc (pool, sizeof (struct rspamd_regexp)); - result->type = type; *end = '\0'; result->regexp = g_regex_new (begin, regexp_flags, 0, &err); result->regexp_text = memory_pool_strdup (pool, begin); |