commit f8d2466: [Minor] Eliminate g_utf8_validate
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Feb 10 11:49:06 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-02-10 11:17:21 +0000
URL: https://github.com/rspamd/rspamd/commit/f8d2466d3a36e8418f2d306ebaaed0ef962737b0
[Minor] Eliminate g_utf8_validate
---
src/libutil/fstring.c | 3 ++-
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;
}
More information about the Commits
mailing list