]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Do not do urf8 escape for non-utf8 regexps
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Oct 2019 13:44:37 +0000 (14:44 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Oct 2019 13:44:37 +0000 (14:44 +0100)
src/libserver/re_cache.c

index 9e84e05d32ad5936b3ea575bc836e5b3297f2a3a..88e346cc563df18624b018eb618c300444ec5668 100644 (file)
@@ -1596,11 +1596,15 @@ rspamd_re_cache_hs_pattern_from_pcre (rspamd_regexp_t *re)
         * https://github.com/intel/hyperscan/issues/133
         */
        const gchar *pat = rspamd_regexp_get_pattern (re);
+       guint flags = rspamd_regexp_get_flags (re), esc_flags = RSPAMD_REGEXP_ESCAPE_RE;
        gchar *escaped;
        gsize esc_len;
 
-       escaped = rspamd_str_regexp_escape (pat, strlen (pat), &esc_len,
-                       RSPAMD_REGEXP_ESCAPE_RE|RSPAMD_REGEXP_ESCAPE_UTF);
+       if (flags & RSPAMD_REGEXP_FLAG_UTF) {
+               esc_flags |= RSPAMD_REGEXP_ESCAPE_UTF;
+       }
+
+       escaped = rspamd_str_regexp_escape (pat, strlen (pat), &esc_len,esc_flags);
 
        return escaped;
 }