aboutsummaryrefslogtreecommitdiffstats
path: root/util/stanza.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2024-11-17 12:35:51 +0100
committerKim Alvefur <zash@zash.se>2024-11-17 12:35:51 +0100
commit00584c4d610a381e4181ab438102420aa601f310 (patch)
treede12daeaa27fe176dc0343df2347b6cd9c1619de /util/stanza.lua
parentb9f73bc7240b87e537f141cf0a4f4c1bef219c3e (diff)
downloadprosody-00584c4d610a381e4181ab438102420aa601f310.tar.gz
prosody-00584c4d610a381e4181ab438102420aa601f310.zip
util.stanza: Handle namespace prefixes for attributes in :find()
More correct handling of namespaces here. This works with both prefixes from the parser and hacky .attr["foo:bar"]
Diffstat (limited to 'util/stanza.lua')
-rw-r--r--util/stanza.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index 77110470..325c494e 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -277,6 +277,10 @@ function stanza_mt:find(path)
local xmlns, name, text;
local char = s_sub(path, pos, pos);
if char == "@" then
+ local prefix, attr = s_match(path, "^([^:]+):(.*)", pos+1);
+ if prefix and self.namespaces and self.namespaces[prefix] then
+ return self.attr[self.namespaces[prefix] .. "\1" .. attr];
+ end
return self.attr[s_sub(path, pos + 1)];
elseif char == "{" then
xmlns, pos = s_match(path, "^([^}]+)}()", pos + 1);