From 99504ef285a3ee86041766df7f85295e3f616ce1 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Tue, 4 Sep 2012 14:07:58 +0200 Subject: [PATCH] Use strict module, but allow plugins Plugins needs permission to create a plugin_descriptor table in the global environment. Permit this until we have extracted the necessary information. Signed-off-by: Tobias Ulmer --- generic/plugin.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/generic/plugin.lua b/generic/plugin.lua index 566573a..111952a 100644 --- a/generic/plugin.lua +++ b/generic/plugin.lua @@ -29,6 +29,7 @@ local plugin = {} local err = require("err") local e2lib = require("e2lib") +local strict = require("strict") --- plugin descriptor -- @class table @@ -82,6 +83,9 @@ local plugins = {} local function load_plugin(dir, p, ctx) local e = err.new("loading plugin failed: %s", p) local plugin_file = string.format("%s/%s", dir, p) + + strict.declare(_G, {plugin_descriptor = {}}) + local chunk, msg = loadfile(plugin_file) if not chunk then return false, e:append("%s", msg) @@ -92,6 +96,9 @@ local function load_plugin(dir, p, ctx) plugin_file) end local pd = plugin_descriptor + + strict.undeclare(_G, {plugin_descriptor = {}}) + if type(pd.description) ~= "string" then e:append("description missing in plugin descriptor") end @@ -241,6 +248,6 @@ function plugin.print_descriptions() end end -return plugin +return strict.lock(plugin) -- vim:sw=4:sts=4:et: -- 2.39.5