aboutsummaryrefslogtreecommitdiffstats
path: root/util-src/encodings.c
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-10-30 16:22:44 +0100
committerKim Alvefur <zash@zash.se>2019-10-30 16:22:44 +0100
commit988243a601855d2f91ea6f9d1057b25a14c62275 (patch)
tree24a23ae603971c7c225e308f11e8704d457fbc44 /util-src/encodings.c
parent571afbf292e67ca92636a6b491ea88fdc1be653d (diff)
downloadprosody-988243a601855d2f91ea6f9d1057b25a14c62275.tar.gz
prosody-988243a601855d2f91ea6f9d1057b25a14c62275.zip
util.encodings: Strictly verify that the 'strict' *prep argument is a boolean
This is to prevent mistakes like nodeprep(username:gsub("a","b")) from unintentionally invoking strict mode.
Diffstat (limited to 'util-src/encodings.c')
-rw-r--r--util-src/encodings.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/util-src/encodings.c b/util-src/encodings.c
index be34032e..4fe83c64 100644
--- a/util-src/encodings.c
+++ b/util-src/encodings.c
@@ -296,8 +296,11 @@ static int icu_stringprep_prep(lua_State *L, const UStringPrepProfile *profile)
}
/* strict */
- if(lua_toboolean(L, 2)) {
- flags = 0;
+ if(!lua_isnoneornil(L, 2)) {
+ luaL_checktype(L, 2, LUA_TBOOLEAN);
+ if(lua_toboolean(L, 2)) {
+ flags = 0;
+ }
}
u_strFromUTF8(unprepped, 1024, &unprepped_len, input, input_len, &err);
@@ -413,8 +416,11 @@ static int stringprep_prep(lua_State *L, const Stringprep_profile *profile) {
s = check_utf8(L, 1, &len);
/* strict */
- if(lua_toboolean(L, 2)) {
- flags = STRINGPREP_NO_UNASSIGNED;
+ if(!lua_isnoneornil(L, 2)) {
+ luaL_checktype(L, 2, LUA_TBOOLEAN);
+ if(lua_toboolean(L, 2)) {
+ flags = STRINGPREP_NO_UNASSIGNED;
+ }
}
if(s == NULL || len >= 1024 || len != strlen(s)) {