Software /
code /
prosody
Diff
util/serialization.lua @ 5021:85b2689dbcfe
Eliminate direct setfenv usage
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 08 Jun 2012 05:04:38 +0200 |
parent | 3745:87f6eabd90c9 |
child | 5776:bd0ff8ae98a8 |
line wrap: on
line diff
--- a/util/serialization.lua Thu Jun 07 23:27:26 2012 +0200 +++ b/util/serialization.lua Fri Jun 08 05:04:38 2012 +0200 @@ -16,11 +16,12 @@ local next = next; local loadstring = loadstring; -local setfenv = setfenv; local pcall = pcall; local debug_traceback = debug.traceback; local log = require "util.logger".init("serialization"); +local envload = require"util.envload".envload; + module "serialization" local indent = function(i) @@ -84,9 +85,8 @@ function deserialize(str) if type(str) ~= "string" then return nil; end str = "return "..str; - local f, err = loadstring(str, "@data"); + local f, err = envload(str, "@data", {}); if not f then return nil, err; end - setfenv(f, {}); local success, ret = pcall(f); if not success then return nil, ret; end return ret;