From 833573efa93d813bab9c973f9b4d7b7c16ef4906 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Mon, 3 Dec 2012 05:49:05 +0500 Subject: plugins/storage/mod_xep0227: Use util.xml. --- plugins/storage/mod_xep0227.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/storage/mod_xep0227.lua b/plugins/storage/mod_xep0227.lua index ac0441b1..5d07a2ea 100644 --- a/plugins/storage/mod_xep0227.lua +++ b/plugins/storage/mod_xep0227.lua @@ -8,7 +8,7 @@ local os_remove = os.remove; local io_open = io.open; local st = require "util.stanza"; -local parse_xml_real = module:require("xmlparse"); +local parse_xml_real = require "util.xml".parse; local function getXml(user, host) local jid = user.."@"..host; -- cgit v1.2.3 From b007f899d502fa17cdce27dfcb2a288b44ba1e89 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Mon, 3 Dec 2012 05:50:39 +0500 Subject: plugins/storage/xmlparse.lib.lua: Delete. --- plugins/storage/xmlparse.lib.lua | 56 ---------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 plugins/storage/xmlparse.lib.lua (limited to 'plugins') diff --git a/plugins/storage/xmlparse.lib.lua b/plugins/storage/xmlparse.lib.lua deleted file mode 100644 index 91063995..00000000 --- a/plugins/storage/xmlparse.lib.lua +++ /dev/null @@ -1,56 +0,0 @@ - -local st = require "util.stanza"; - --- XML parser -local parse_xml = (function() - local entity_map = setmetatable({ - ["amp"] = "&"; - ["gt"] = ">"; - ["lt"] = "<"; - ["apos"] = "'"; - ["quot"] = "\""; - }, {__index = function(_, s) - if s:sub(1,1) == "#" then - if s:sub(2,2) == "x" then - return string.char(tonumber(s:sub(3), 16)); - else - return string.char(tonumber(s:sub(2))); - end - end - end - }); - local function xml_unescape(str) - return (str:gsub("&(.-);", entity_map)); - end - local function parse_tag(s) - local name,sattr=(s):gmatch("([^%s]+)(.*)")(); - local attr = {}; - for a,b in (sattr):gmatch("([^=%s]+)=['\"]([^'\"]*)['\"]") do attr[a] = xml_unescape(b); end - return name, attr; - end - return function(xml) - local stanza = st.stanza("root"); - local regexp = "<([^>]*)>([^<]*)"; - for elem, text in xml:gmatch(regexp) do - if elem:sub(1,1) == "!" or elem:sub(1,1) == "?" then -- neglect comments and processing-instructions - elseif elem:sub(1,1) == "/" then -- end tag - elem = elem:sub(2); - stanza:up(); -- TODO check for start-end tag name match - elseif elem:sub(-1,-1) == "/" then -- empty tag - elem = elem:sub(1,-2); - local name,attr = parse_tag(elem); - stanza:tag(name, attr):up(); - else -- start tag - local name,attr = parse_tag(elem); - stanza:tag(name, attr); - end - if #text ~= 0 then -- text - stanza:text(xml_unescape(text)); - end - end - return stanza.tags[1]; - end -end)(); --- end of XML parser - -return parse_xml; -- cgit v1.2.3