From 026b1a34f5259c7cb907c4954bd3d27c9a3a961d Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Thu, 23 Aug 2012 22:10:36 +0100 Subject: CLOD: Ensure we can't set functions or tables as clod entries --- lib/clod.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/clod.lua b/lib/clod.lua index 54c83d4..3e70ca2 100644 --- a/lib/clod.lua +++ b/lib/clod.lua @@ -76,6 +76,9 @@ function settings_mt:__newindex(subkey, value) local meta = metadata[self] local confmeta = metadata[meta.conf] local key = subkey + if type(value) == "table" or type(value) == "function" then + error("Clod does not support " .. type(value) .. "s as values") + end if meta.prefix then key = meta.prefix .. "." .. subkey end @@ -234,9 +237,15 @@ local function parse_config(conf, confname) end function parse_mt:__newindex(key, value) -- This is the equivalent of 'foo = "bar"' instead of 'foo "bar"' + if type(value) == "table" or type(value) == "function" then + error("Clod does not support " .. type(value) .. "s as values") + end return self[key](value) end function parse_mt:__call(value) + if type(value) == "table" or type(value) == "function" then + error("Clod does not support " .. type(value) .. "s as values") + end local key = assert(keys[self]) local curline = getinfo(2, "Snlf").currentline local entry = { key = key, value = value, lineno = curline } -- cgit v1.2.1