]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Eliminate g_utf8_validate
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 10 Feb 2020 11:17:21 +0000 (11:17 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 10 Feb 2020 11:46:43 +0000 (11:46 +0000)
src/libutil/fstring.c
src/libutil/regexp.c

index b00b71e121f374a88a6b61be50edaf74d73e887f..652d72d1434e66697e51078f59f37df308d572b4 100644 (file)
@@ -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) {
index b91ab819e6e613abf670ba831db0b1bf30dc340c..0216c95e8c22e63a97c677c245826e49be78ec29 100644 (file)
@@ -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;
                }