diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-14 15:17:24 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-14 15:17:24 +0100 |
commit | 4d1669e4b40e8a8e93ab652a60ed35ea64cf14da (patch) | |
tree | 7a703f756f47b774acc5e5f10781324dfbbca837 /src | |
parent | a5a312b65b3aa2539eeb483a04126f5f6a2b0014 (diff) | |
download | rspamd-4d1669e4b40e8a8e93ab652a60ed35ea64cf14da.tar.gz rspamd-4d1669e4b40e8a8e93ab652a60ed35ea64cf14da.zip |
[Feature] Allow to have different flags for different patterns
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/url.c | 6 | ||||
-rw-r--r-- | src/libutil/multipattern.c | 8 | ||||
-rw-r--r-- | src/libutil/multipattern.h | 2 | ||||
-rw-r--r-- | src/lua/lua_trie.c | 8 |
4 files changed, 13 insertions, 11 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c index 95ab8f039..95542c1f0 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -392,7 +392,8 @@ rspamd_url_parse_tld_file (const gchar *fname, #endif m.flags = flags; - rspamd_multipattern_add_pattern (url_scanner->search_trie, p); + rspamd_multipattern_add_pattern (url_scanner->search_trie, p, + RSPAMD_MULTIPATTERN_TLD | RSPAMD_MULTIPATTERN_ICASE); m.pattern = rspamd_multipattern_get_pattern (url_scanner->search_trie, rspamd_multipattern_get_npatterns (url_scanner->search_trie) - 1); m.patlen = strlen (m.pattern); @@ -412,7 +413,8 @@ rspamd_url_add_static_matchers (struct url_match_scanner *sc) for (i = 0; i < n; i++) { rspamd_multipattern_add_pattern (url_scanner->search_trie, - static_matchers[i].pattern); + static_matchers[i].pattern, + RSPAMD_MULTIPATTERN_ICASE); } } diff --git a/src/libutil/multipattern.c b/src/libutil/multipattern.c index d5e038654..f6a017047 100644 --- a/src/libutil/multipattern.c +++ b/src/libutil/multipattern.c @@ -384,7 +384,7 @@ rspamd_multipattern_create_sized (guint npatterns, void rspamd_multipattern_add_pattern (struct rspamd_multipattern *mp, - const gchar *pattern) + const gchar *pattern, gint flags) { g_assert (pattern != NULL); g_assert (mp != NULL); @@ -402,14 +402,14 @@ rspamd_multipattern_add_pattern (struct rspamd_multipattern *mp, } g_array_append_val (mp->hs_flags, fl); - np = rspamd_multipattern_pattern_filter (pattern, mp->flags); + np = rspamd_multipattern_pattern_filter (pattern, flags); g_array_append_val (mp->hs_pats, np); fl = mp->cnt; g_array_append_val (mp->hs_ids, fl); #else ac_trie_pat_t pat; - pat.ptr = rspamd_multipattern_pattern_filter (pattern, mp->flags); + pat.ptr = rspamd_multipattern_pattern_filter (pattern, flags); pat.len = strlen (pat.ptr); g_array_append_val (mp->pats, pat); @@ -431,7 +431,7 @@ rspamd_multipattern_create_full (const gchar **patterns, mp = rspamd_multipattern_create_sized (npatterns, flags); for (i = 0; i < npatterns; i++) { - rspamd_multipattern_add_pattern (mp, patterns[i]); + rspamd_multipattern_add_pattern (mp, patterns[i], flags); } return mp; diff --git a/src/libutil/multipattern.h b/src/libutil/multipattern.h index 345bfe33f..e956b9182 100644 --- a/src/libutil/multipattern.h +++ b/src/libutil/multipattern.h @@ -91,7 +91,7 @@ struct rspamd_multipattern *rspamd_multipattern_create_full ( * @param pattern */ void rspamd_multipattern_add_pattern (struct rspamd_multipattern *mp, - const gchar *pattern); + const gchar *pattern, gint flags); /** * Compiles multipattern structure diff --git a/src/lua/lua_trie.c b/src/lua/lua_trie.c index c02beaf27..5803a1d0b 100644 --- a/src/lua/lua_trie.c +++ b/src/lua/lua_trie.c @@ -88,7 +88,7 @@ static gint lua_trie_create (lua_State *L) { struct rspamd_multipattern *trie, **ptrie; - gint npat = 0; + gint npat = 0, flags = RSPAMD_MULTIPATTERN_ICASE|RSPAMD_MULTIPATTERN_GLOB; GError *err = NULL; if (!lua_istable (L, 1)) { @@ -107,13 +107,13 @@ lua_trie_create (lua_State *L) lua_pop (L, 1); } - trie = rspamd_multipattern_create_sized (npat, - RSPAMD_MULTIPATTERN_ICASE|RSPAMD_MULTIPATTERN_GLOB); + trie = rspamd_multipattern_create_sized (npat, flags); lua_pushnil (L); while (lua_next (L, -2) != 0) { if (lua_isstring (L, -1)) { - rspamd_multipattern_add_pattern (trie, lua_tostring (L, -1)); + rspamd_multipattern_add_pattern (trie, lua_tostring (L, -1), + flags); } lua_pop (L, 1); |