diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-21 14:44:07 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-21 14:44:07 +0100 |
commit | d22abb557ecda41ab076b4c777dfd4c95340fbfd (patch) | |
tree | e990c3ceda9460145e5a075b848bde0d1789b0bd /src/libutil/str_util.c | |
parent | 4fe53c718fe00ed1964a7ec099ff579168eb0cbb (diff) | |
download | rspamd-d22abb557ecda41ab076b4c777dfd4c95340fbfd.tar.gz rspamd-d22abb557ecda41ab076b4c777dfd4c95340fbfd.zip |
[Minor] Fix utf8 regexps escaping
Diffstat (limited to 'src/libutil/str_util.c')
-rw-r--r-- | src/libutil/str_util.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index f5cd8be1a..f325b35f6 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -2725,7 +2725,7 @@ rspamd_str_regexp_escape (const gchar *pattern, gsize slen, gsize len; static const gchar hexdigests[16] = "0123456789abcdef"; - len = slen; + len = 0; p = pattern; /* [-[\]{}()*+?.,\\^$|#\s] need to be escaped */ @@ -2781,13 +2781,10 @@ rspamd_str_regexp_escape (const gchar *pattern, gsize slen, } } - if (slen == len) { - if (dst_len) { - - if (tmp_utf) { - slen = strlen (tmp_utf); - } + if (len == 0) { + /* No need to escape anything */ + if (dst_len) { *dst_len = slen; } @@ -2799,10 +2796,12 @@ rspamd_str_regexp_escape (const gchar *pattern, gsize slen, } } + /* Escape logic */ if (tmp_utf) { pattern = tmp_utf; } + len = slen + len; res = g_malloc (len + 1); p = pattern; d = res; |