diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-07-01 21:14:52 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-07-01 21:14:52 +0100 |
commit | eb28cc845c2e1063e6b1111519164e12ce2bed4e (patch) | |
tree | f86927d4e6566a0fe02ff241d23aa6c6282ae786 /src/lua/lua_text.c | |
parent | e002ae90a10ee76da8c0c66427ec454ee87bd1d9 (diff) | |
download | rspamd-eb28cc845c2e1063e6b1111519164e12ce2bed4e.tar.gz rspamd-eb28cc845c2e1063e6b1111519164e12ce2bed4e.zip |
[Minor] Implement binary string checks
Issue: #4204
Diffstat (limited to 'src/lua/lua_text.c')
-rw-r--r-- | src/lua/lua_text.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lua/lua_text.c b/src/lua/lua_text.c index 19317bf59..04a416942 100644 --- a/src/lua/lua_text.c +++ b/src/lua/lua_text.c @@ -348,6 +348,23 @@ lua_new_text (lua_State *L, const gchar *start, gsize len, gboolean own) return t; } +bool +lua_is_text_binary(struct rspamd_lua_text *t) +{ + if (t == NULL || t->len == 0) { + return false; + } + + if (rspamd_str_has_8bit(t->start, t->len)) { + if (rspamd_fast_utf8_validate(t->start, t->len) == 0) { + return true; + } + return false; + } + + return true; +} + static gint lua_text_fromstring (lua_State *L) |