aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorIKEDA Soji <mail@ikedas.net>2024-05-02 22:34:09 +0900
committerIKEDA Soji <mail@ikedas.net>2024-05-03 09:07:19 +0900
commit2e742c54918ea0d01fbba57148d140b664f4915c (patch)
treeaea635044947a54aac1470d0da8a30af932e0efe /src/lua
parent073d6f00eb4555977de895001e35de78ef6e103c (diff)
downloadrspamd-2e742c54918ea0d01fbba57148d140b664f4915c.tar.gz
rspamd-2e742c54918ea0d01fbba57148d140b664f4915c.zip
SUBJ_ALL_CAPS is overkill
It should consider characters in unicase scripts as being not uppercase.
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_util.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 3370a757d..92f831f6f 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -1421,7 +1421,7 @@ lua_util_is_uppercase(lua_State *L)
LUA_TRACE_POINT;
int32_t i = 0;
UChar32 uc;
- unsigned int nlc = 0, nuc = 0;
+ bool is_upper = false, is_lower = false, is_other = false;
struct rspamd_lua_text *t = lua_check_text_or_string(L, 1);
if (t) {
@@ -1433,15 +1433,20 @@ lua_util_is_uppercase(lua_State *L)
}
if (u_isupper(uc)) {
- nuc++;
+ is_upper = true;
}
else if (u_islower(uc)) {
- nlc++;
+ is_lower = true;
+ break;
+ }
+ else if (u_charType(uc) == U_OTHER_LETTER) {
+ is_other = true;
+ break;
}
}
}
- if (nuc > 0 && nlc == 0) {
+ if (is_upper && !is_lower && !is_other) {
lua_pushboolean(L, TRUE);
}
else {