aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-10 15:38:34 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-10 15:38:34 +0000
commit576108c64c01901848010673efc53b46a24dbc92 (patch)
tree5df2355d81d48ed1534c62817398cea0e186c1a2 /src/libserver
parent1aed295e93e1153bff796f9c2472f7e318ae1e28 (diff)
downloadrspamd-576108c64c01901848010673efc53b46a24dbc92.tar.gz
rspamd-576108c64c01901848010673efc53b46a24dbc92.zip
Add special flag to disable hyperscan for particular expressions
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/re_cache.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index cf9caa7f0..8d728b02e 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -992,7 +992,7 @@ rspamd_re_cache_compile_hyperscan (struct rspamd_re_cache *cache,
struct rspamd_re_class *re_class;
gchar path[PATH_MAX];
hs_database_t *test_db;
- gint fd, i, n, *hs_ids = NULL, pcre_flags;
+ gint fd, i, n, *hs_ids = NULL, pcre_flags, re_flags;
guint64 crc;
rspamd_regexp_t *re;
hs_compile_error_t *hs_errors;
@@ -1045,6 +1045,12 @@ rspamd_re_cache_compile_hyperscan (struct rspamd_re_cache *cache,
hs_flags[i] = 0;
pcre_flags = rspamd_regexp_get_pcre_flags (re);
+ re_flags = rspamd_regexp_get_flags (re);
+
+ if (re_flags & RSPAMD_REGEXP_FLAG_PCRE_ONLY) {
+ /* Do not try to compile bad regexp */
+ continue;
+ }
if (pcre_flags & PCRE_UTF8) {
hs_flags[i] |= HS_FLAG_UTF8;
@@ -1055,6 +1061,9 @@ rspamd_re_cache_compile_hyperscan (struct rspamd_re_cache *cache,
if (pcre_flags & PCRE_MULTILINE) {
hs_flags[i] |= HS_FLAG_MULTILINE;
}
+ if (pcre_flags & PCRE_DOTALL) {
+ hs_flags[i] |= HS_FLAG_DOTALL;
+ }
if (rspamd_regexp_get_maxhits (re) == 1) {
hs_flags[i] |= HS_FLAG_SINGLEMATCH;
}