mod_admin_shell: Tighten up type checks to fix #1754 (thanks clouded) 0.12
authorKim Alvefur <zash@zash.se>
Sun, 15 May 2022 23:16:14 +0200
branch0.12
changeset 12509 604bb5b8362d
parent 12504 88e1b94105ae
child 12510 d04f6f014636
child 12511 e242a6e74424
mod_admin_shell: Tighten up type checks to fix #1754 (thanks clouded) Due to the dummy statistics provider (see core.statsmanager line 250) having a metatable that allows infinite indexing where everything is always the same table, which end up in suf() in the concatenation line.
plugins/mod_admin_shell.lua
--- a/plugins/mod_admin_shell.lua	Mon May 09 22:39:05 2022 +0200
+++ b/plugins/mod_admin_shell.lua	Sun May 15 23:16:14 2022 +0200
@@ -49,12 +49,12 @@
 end
 
 local function pre(prefix, str, alt)
-	if (str or "") == "" then return alt or ""; end
+	if type(str) ~= "string" or str == "" then return alt or ""; end
 	return prefix .. str;
 end
 
 local function suf(str, suffix, alt)
-	if (str or "") == "" then return alt or ""; end
+	if type(str) ~= "string" or str == "" then return alt or ""; end
 	return str .. suffix;
 end