From a3e21e6d576ecfd2b348a39fb1ebc4c8723b9315 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Tue, 14 Oct 2008 09:54:49 +0500 Subject: Fixed: util/jid.lua now returns module object --- util/jid.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util') diff --git a/util/jid.lua b/util/jid.lua index 28dd1a92..784d2b64 100644 --- a/util/jid.lua +++ b/util/jid.lua @@ -10,3 +10,5 @@ function split(jid) local resource = match(jid, "/(.+)$"); return node, server, resource; end + +return _M; \ No newline at end of file -- cgit v1.2.3 From 2a2956ef53942cb20ea53d0216dc6e9af6185e5c Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Wed, 22 Oct 2008 21:18:50 +0500 Subject: Minor edit, and added a TODO --- util/jid.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/jid.lua b/util/jid.lua index 784d2b64..b1e4131d 100644 --- a/util/jid.lua +++ b/util/jid.lua @@ -4,7 +4,8 @@ local match = string.match; module "jid" function split(jid) - if not jid then return nil; end + if not jid then return; end + -- TODO verify JID, and return; if invalid local node = match(jid, "^([^@]+)@"); local server = (node and match(jid, ".-@([^@/]+)")) or match(jid, "^([^@/]+)"); local resource = match(jid, "/(.+)$"); -- cgit v1.2.3 From c3ca55e0195d03c3e0c23590c387c49068be7723 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Thu, 23 Oct 2008 02:49:43 +0500 Subject: Fixed: datamanager.store and datamanager.load could crash when username or host arguments were nil. (useful for server specific and global data). --- util/datamanager.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'util') diff --git a/util/datamanager.lua b/util/datamanager.lua index 1deb6b3d..f4ae958c 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -68,16 +68,25 @@ end function load(username, host, datastore) local data, ret = loadfile(getpath(username, host, datastore)); - if not data then log("warn", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..username.."@"..host); return nil; end + if not data then + log("warn", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or nil).."@"..(host or nil)); + return nil; + end setfenv(data, {}); local success, ret = pcall(data); - if not success then log("error", "Unable to load "..datastore.." storage ('"..ret.."') for user: "..username.."@"..host); return nil; end + if not success then + log("error", "Unable to load "..datastore.." storage ('"..ret.."') for user: "..(username or nil).."@"..(host or nil)); + return nil; + end return ret; end function store(username, host, datastore, data) local f, msg = io_open(getpath(username, host, datastore), "w+"); - if not f then log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..username.."@"..host); return nil; end + if not f then + log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or nil).."@"..(host or nil)); + return nil; + end f:write("return "); simplesave(f, data); f:close(); -- cgit v1.2.3