aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libutil/str_util.c13
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;