# HG changeset patch # User Kim Alvefur # Date 1572448964 -3600 # Node ID 4ef785f45aa23eceab5ee2b30e62b760dbf45c8d # Parent a77d9b3885bb506957a1dc9f253f0df3b8ce19fd 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. diff -r a77d9b3885bb -r 4ef785f45aa2 util-src/encodings.c --- a/util-src/encodings.c Mon Sep 09 22:15:04 2019 +0200 +++ b/util-src/encodings.c Wed Oct 30 16:22:44 2019 +0100 @@ -296,8 +296,11 @@ } /* 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 @@ 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)) {