Mercurial > prosody-modules
comparison mod_storage_appendmap/mod_storage_appendmap.lua @ 2205:98354fbea63c
mod_storage_appendmap: Prevent _ENV = false
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 09 Jun 2016 11:47:55 +0200 |
| parents | 8f7083b980cf |
| children | a2625a36c092 |
comparison
equal
deleted
inserted
replaced
| 2204:affccf479f89 | 2205:98354fbea63c |
|---|---|
| 30 end | 30 end |
| 31 | 31 |
| 32 function map:set_keys(user, keyvalues) | 32 function map:set_keys(user, keyvalues) |
| 33 local keys, values = {}, {}; | 33 local keys, values = {}, {}; |
| 34 if _VERSION == "Lua 5.1" then | 34 if _VERSION == "Lua 5.1" then |
| 35 assert(not keyvalues._ENV, "'_ENV' is a restricted key"); | 35 assert(keyvalues._ENV == nil, "'_ENV' is a restricted key"); |
| 36 end | 36 end |
| 37 for key, value in pairs(keyvalues) do | 37 for key, value in pairs(keyvalues) do |
| 38 module:log("debug", "user %s sets %q to %s", user, key, tostring(value)) | 38 module:log("debug", "user %s sets %q to %s", user, key, tostring(value)) |
| 39 if type(key) ~= "string" or not key:find("^[%w_][%w%d_]*$") or key == "_ENV" then | 39 if type(key) ~= "string" or not key:find("^[%w_][%w%d_]*$") or key == "_ENV" then |
| 40 key = "_ENV[" .. dump(key) .. "]"; | 40 key = "_ENV[" .. dump(key) .. "]"; |
