diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-31 13:27:00 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-31 13:27:00 +0100 |
commit | a3ef64be4a40f1a57914573d8f686a398652640b (patch) | |
tree | 427a55ded970f8c0e8c189f6e6cc1702e0a92adb /src/lua/lua_task.c | |
parent | e95c0ba5d42e1753faa9a35697f1074121c30775 (diff) | |
download | rspamd-a3ef64be4a40f1a57914573d8f686a398652640b.tar.gz rspamd-a3ef64be4a40f1a57914573d8f686a398652640b.zip |
Add function to test whether textpart is utf.
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r-- | src/lua/lua_task.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index e8814e871..96292bee8 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -499,6 +499,8 @@ static const struct luaL_reg tasklib_m[] = { * This module provides access to text parts found in a message */ +LUA_FUNCTION_DEF (textpart, is_utf); + /*** * @method textpart:get_content() * Get parsed content of a part @@ -544,6 +546,7 @@ LUA_FUNCTION_DEF (textpart, get_language); LUA_FUNCTION_DEF (textpart, compare_distance); static const struct luaL_reg textpartlib_m[] = { + LUA_INTERFACE_DEF (textpart, is_utf), LUA_INTERFACE_DEF (textpart, get_content), LUA_INTERFACE_DEF (textpart, get_length), LUA_INTERFACE_DEF (textpart, is_empty), @@ -2026,6 +2029,26 @@ end */ /*** + * @method text_part:is_utf() + * Return TRUE if part is a valid utf text + * @return {boolean} true if part is valid `UTF8` part + */ +static gint +lua_textpart_is_utf (lua_State * L) +{ + struct mime_text_part *part = lua_check_textpart (L); + + if (part == NULL || part->is_empty) { + lua_pushboolean (L, FALSE); + return 1; + } + + lua_pushboolean (L, part->is_utf); + + return 1; +} + +/*** * @method text_part:get_content() * Get the text of the part * @return {string} `UTF8` encoded content of the part |