aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-01-18 19:00:18 +0000
committerMatthew Wild <mwild1@gmail.com>2010-01-18 19:00:18 +0000
commit0f8fb8c50feb46c932ac46faf254cb74fc28ddf9 (patch)
tree36389925a25cf8621e9017f8303c651c7f13b1ac
parentc13e080420cc7cf3c7d6399a023f08f0aa6e9037 (diff)
downloadprosody-0f8fb8c50feb46c932ac46faf254cb74fc28ddf9.tar.gz
prosody-0f8fb8c50feb46c932ac46faf254cb74fc28ddf9.zip
xmlhandlers: Define ns_separator and ns_pattern to save repeating it in literal form throughout the file
-rw-r--r--core/xmlhandlers.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua
index 82c2d0b8..c59f9df8 100644
--- a/core/xmlhandlers.lua
+++ b/core/xmlhandlers.lua
@@ -26,6 +26,8 @@ module "xmlhandlers"
local ns_prefixes = {
["http://www.w3.org/XML/1998/namespace"] = "xml";
}
+local ns_separator = "\1";
+local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$";
function init_xmlhandlers(session, stream_callbacks)
local ns_stack = { "" };
@@ -49,7 +51,7 @@ function init_xmlhandlers(session, stream_callbacks)
stanza:text(t_concat(chardata));
chardata = {};
end
- local curr_ns,name = tagname:match("^([^\1]*)\1?(.*)$");
+ local curr_ns,name = tagname:match(ns_pattern);
if name == "" then
curr_ns, name = "", curr_ns;
end
@@ -62,7 +64,7 @@ function init_xmlhandlers(session, stream_callbacks)
for i=1,#attr do
local k = attr[i];
attr[i] = nil;
- local ns, nm = k:match("^([^\1]*)\1?(.*)$");
+ local ns, nm = k:match(ns_pattern);
if nm ~= "" then
ns = ns_prefixes[ns];
if ns then
@@ -104,7 +106,7 @@ function init_xmlhandlers(session, stream_callbacks)
end
end
function xml_handlers:EndElement(tagname)
- local curr_ns,name = tagname:match("^([^\1]*)\1?(.*)$");
+ local curr_ns,name = tagname:match(ns_pattern);
if name == "" then
curr_ns, name = "", curr_ns;
end