From 4361bfcb4da0b6f9de74c7de9f2d08084877713e Mon Sep 17 00:00:00 2001 From: HybridDog <3192173+HybridDog@users.noreply.github.com> Date: Wed, 22 Apr 2020 00:07:12 +0200 Subject: Fix configuration caching in log_deprecated (#9697) * Fix configuration caching in log_deprecated The configured variable was never set to true. I've set the variables to thread_local because the configuration should be reloaded after reentering the world from mainmenu. --- src/script/lua_api/l_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/script/lua_api/l_util.cpp') diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp index ae3e5df3d..28ee39fc8 100644 --- a/src/script/lua_api/l_util.cpp +++ b/src/script/lua_api/l_util.cpp @@ -44,7 +44,7 @@ with this program; if not, write to the Free Software Foundation, Inc., // log([level,] text) // Writes a line to the logger. -// The one-argument version logs to infostream. +// The one-argument version logs to LL_NONE. // The two-argument version accepts a log level. // Either the special case "deprecated" for deprecation notices, or any specified in // Logger::stringToLevel(name). -- cgit v1.2.3 From e79bc40c0a5312baf4e8c3e33048d50b41b4a2ff Mon Sep 17 00:00:00 2001 From: Lejo1 Date: Wed, 20 May 2020 21:54:52 +0200 Subject: Check for valid base64 before decoding (#9904) --- doc/lua_api.txt | 2 +- src/script/lua_api/l_util.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/script/lua_api/l_util.cpp') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 0101bd4cf..bd0cb8acb 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -5449,7 +5449,7 @@ Misc. * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"` * `minetest.encode_base64(string)`: returns string encoded in base64 * Encodes a string in base64. -* `minetest.decode_base64(string)`: returns string +* `minetest.decode_base64(string)`: returns string or nil for invalid base64 * Decodes a string encoded in base64. * `minetest.is_protected(pos, name)`: returns boolean * Returning `true` restricts the player `name` from modifying (i.e. digging, diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp index 28ee39fc8..cd63e20c2 100644 --- a/src/script/lua_api/l_util.cpp +++ b/src/script/lua_api/l_util.cpp @@ -318,9 +318,13 @@ int ModApiUtil::l_decode_base64(lua_State *L) NO_MAP_LOCK_REQUIRED; size_t size; - const char *data = luaL_checklstring(L, 1, &size); + const char *d = luaL_checklstring(L, 1, &size); + const std::string data = std::string(d, size); + + if (!base64_is_valid(data)) + return 0; - std::string out = base64_decode(std::string(data, size)); + std::string out = base64_decode(data); lua_pushlstring(L, out.data(), out.size()); return 1; -- cgit v1.2.3