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
commit42aeda373c62b60224608b188b4a776afe534511 (patch)
tree24a23ae603971c7c225e308f11e8704d457fbc44 /util-src/encodings.c
parent31d6d1a42b9928648961f418dedfa778e60bc0ba (diff)
downloadprosody-42aeda373c62b60224608b188b4a776afe534511.tar.gz
prosody-42aeda373c62b60224608b188b4a776afe534511.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)) {