util.paseto: Do strict type check in pae() function
authorKim Alvefur <zash@zash.se>
Mon, 11 Jul 2022 18:48:57 +0200
changeset 12720 0b68b021ce46
parent 12719 5dd00f806e32
child 12721 898e99f49d80
util.paseto: Do strict type check in pae() function Fixes a test failure on Lua 5.4 where ipairs("") does not produce an error.
util/paseto.lua
--- a/util/paseto.lua	Mon Jul 11 17:11:38 2022 +0200
+++ b/util/paseto.lua	Mon Jul 11 18:48:57 2022 +0200
@@ -23,6 +23,9 @@
 end
 
 local function pae(parts)
+	if type(parts) ~= "table" then
+		error("bad argument #1 to 'pae' (table expected, got "..type(parts)..")");
+	end
 	local o = { le64(#parts) };
 	for _, part in ipairs(parts) do
 		table.insert(o, le64(#part)..part);