commit d22abb5: [Minor] Fix utf8 regexps escaping
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Oct 21 13:49:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-21 14:44:07 +0100
URL: https://github.com/rspamd/rspamd/commit/d22abb557ecda41ab076b4c777dfd4c95340fbfd
[Minor] Fix utf8 regexps escaping
---
src/libutil/str_util.c | 13 ++++++-------
1 file 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;
More information about the Commits
mailing list