diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-10 11:17:21 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-10 11:46:43 +0000 |
commit | f8d2466d3a36e8418f2d306ebaaed0ef962737b0 (patch) | |
tree | 9787f302af8d168bd5c587bd4e76c7a7d6c54856 | |
parent | 9091c3739b5f99a0a29e5c7a64fc93bef83955d6 (diff) | |
download | rspamd-f8d2466d3a36e8418f2d306ebaaed0ef962737b0.tar.gz rspamd-f8d2466d3a36e8418f2d306ebaaed0ef962737b0.zip |
[Minor] Eliminate g_utf8_validate
-rw-r--r-- | src/libutil/fstring.c | 3 | ||||
-rw-r--r-- | src/libutil/regexp.c | 9 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index b00b71e12..652d72d14 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -15,6 +15,7 @@ */ #include "fstring.h" #include "str_util.h" +#include "contrib/fastutf8/fastutf8.h" #ifdef WITH_JEMALLOC @@ -274,7 +275,7 @@ rspamd_fstrhash_lc (const rspamd_ftok_t * str, gboolean is_utf) if (is_utf) { while (end < str->begin + str->len) { - if (!g_utf8_validate (p, str->len, &end)) { + if (rspamd_fast_utf8_validate (p, str->len) != 0) { return rspamd_fstrhash_lc (str, FALSE); } while (p < end) { diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index b91ab819e..0216c95e8 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -19,6 +19,7 @@ #include "ref.h" #include "util.h" #include "rspamd.h" +#include "contrib/fastutf8/fastutf8.h" #ifndef WITH_PCRE2 /* Normal pcre path */ @@ -576,11 +577,11 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, r = re->re; ext = re->extra; #if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) && !defined(DISABLE_JIT_FAST) - if (g_utf8_validate (mt, remain, NULL)) { + if (rspamd_fast_utf8_validate (mt, remain) == 0) { st = global_re_cache->jstack; } else { - msg_err ("bad utf8 input for JIT re"); + msg_err ("bad utf8 input for JIT re '%s'", re->pattern); return FALSE; } #endif @@ -717,8 +718,8 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, #ifdef HAVE_PCRE_JIT if (!(re->flags & RSPAMD_REGEXP_FLAG_DISABLE_JIT) && can_jit) { - if (re->re != re->raw_re && !g_utf8_validate (mt, remain, NULL)) { - msg_err ("bad utf8 input for JIT re"); + if (re->re != re->raw_re && rspamd_fast_utf8_validate (mt, remain) != 0) { + msg_err ("bad utf8 input for JIT re '%s'", re->pattern); return FALSE; } |