summaryrefslogtreecommitdiffstats
path: root/src/lua/lua_util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-07 09:44:58 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-07 09:45:16 +0100
commit545e090c81ce22bbb7edb6d3621c348bd994449c (patch)
treeda40261b3a037e705d49b58b386b899e30c19fe4 /src/lua/lua_util.c
parentc207930dc64a680cc9a1ae9075e66f9d963e32e4 (diff)
downloadrspamd-545e090c81ce22bbb7edb6d3621c348bd994449c.tar.gz
rspamd-545e090c81ce22bbb7edb6d3621c348bd994449c.zip
[Minor] Fix some more suspicious cases
Diffstat (limited to 'src/lua/lua_util.c')
-rw-r--r--src/lua/lua_util.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 25fdc1514..ec5f98c22 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -2513,30 +2513,41 @@ lua_util_is_utf_mixed_script(lua_State *L)
{
LUA_TRACE_POINT;
gsize len_of_string;
- const gchar *string_to_check = lua_tolstring (L, 1, &len_of_string);
+ const guchar *string_to_check = lua_tolstring (L, 1, &len_of_string);
UScriptCode last_script_code = USCRIPT_INVALID_CODE;
UErrorCode uc_err = U_ZERO_ERROR;
if (string_to_check) {
uint index = 0;
UChar32 char_to_check = 0;
- while(index < len_of_string) {
- U8_NEXT(string_to_check, index, len_of_string, char_to_check);
- if (char_to_check < 0 ) {
+
+ while (index < len_of_string) {
+ U8_NEXT (string_to_check, index, len_of_string, char_to_check);
+
+ if (char_to_check < 0) {
return luaL_error (L, "passed string is not valid utf");
}
- UScriptCode current_script_code = uscript_getScript(char_to_check, &uc_err);
- if (uc_err != U_ZERO_ERROR){
- msg_err ("cannot get unicode script for character, error: %s", u_errorName (uc_err));
+
+ UScriptCode current_script_code = uscript_getScript (char_to_check, &uc_err);
+
+ if (uc_err != U_ZERO_ERROR) {
+ msg_err ("cannot get unicode script for character, error: %s",
+ u_errorName (uc_err));
lua_pushboolean (L, false);
+
return 1;
}
- if ( current_script_code != USCRIPT_COMMON && current_script_code != USCRIPT_INHERITED ){
- if (last_script_code == USCRIPT_INVALID_CODE ){
+
+ if (current_script_code != USCRIPT_COMMON &&
+ current_script_code != USCRIPT_INHERITED) {
+
+ if (last_script_code == USCRIPT_INVALID_CODE) {
last_script_code = current_script_code;
- } else {
- if ( last_script_code != current_script_code ){
+ }
+ else {
+ if (last_script_code != current_script_code) {
lua_pushboolean (L, true);
+
return 1;
}
}