From: Vsevolod Stakhov Date: Thu, 14 Feb 2019 17:27:18 +0000 (+0000) Subject: [Minor] Use new logic of regexp escaping X-Git-Tag: 1.9.0~149 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ec6e8f945f6a1fb6a2efc2bd17b3545cd7b3b3b6;p=rspamd.git [Minor] Use new logic of regexp escaping --- diff --git a/src/libutil/multipattern.c b/src/libutil/multipattern.c index e4a39d5fe..c1d0d6499 100644 --- a/src/libutil/multipattern.c +++ b/src/libutil/multipattern.c @@ -116,11 +116,11 @@ rspamd_multipattern_escape_tld_hyperscan (const gchar *pattern, gsize slen, p ++; } - prefix = "\\..*\\."; + prefix = ".*"; } else { len = slen + 2; - prefix = "\\."; + prefix = "."; p = pattern; } @@ -200,11 +200,18 @@ rspamd_multipattern_pattern_filter (const gchar *pattern, gsize len, } if (flags & RSPAMD_MULTIPATTERN_TLD) { - ret = rspamd_multipattern_escape_tld_hyperscan (pattern, len, dst_len); + gchar *tmp; + gsize tlen; + tmp = rspamd_multipattern_escape_tld_hyperscan (pattern, len, &tlen); + + ret = rspamd_str_regexp_escape (tmp, tlen, dst_len, + gl_flags|RSPAMD_REGEXP_ESCAPE_GLOB); + g_free (tmp); } else if (flags & RSPAMD_MULTIPATTERN_RE) { ret = malloc (len + 1); - *dst_len = rspamd_strlcpy (ret, pattern, len + 1); + ret = rspamd_str_regexp_escape (pattern, len, dst_len, gl_flags | + RSPAMD_REGEXP_ESCAPE_RE); } else if (flags & RSPAMD_MULTIPATTERN_GLOB) { ret = rspamd_str_regexp_escape (pattern, len, dst_len,