From 6439cbcfe679ebb06b8a09c97c890cb978fc5768 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 21 Oct 2019 14:44:37 +0100 Subject: [PATCH] [Minor] Do not do urf8 escape for non-utf8 regexps --- src/libserver/re_cache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index 9e84e05d3..88e346cc5 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -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; } -- 2.39.5