mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.stanza: Handle Clark notation for attributes in :find()
This commit is contained in:
parent
00584c4d61
commit
885fde62be
2 changed files with 4 additions and 0 deletions
|
@ -580,6 +580,7 @@ describe("util.stanza", function()
|
|||
it("handles namespaced attributes", function()
|
||||
local s = st.stanza("root", { ["urn:example:namespace\1attr"] = "value" }, { e = "urn:example:namespace" });
|
||||
assert.equal("value", s:find("@e:attr"), "finds prefixed attr")
|
||||
assert.equal("value", s:find("@{urn:example:namespace}attr"), "finds clark attr")
|
||||
end)
|
||||
end);
|
||||
end);
|
||||
|
|
|
@ -277,6 +277,9 @@ function stanza_mt:find(path)
|
|||
local xmlns, name, text;
|
||||
local char = s_sub(path, pos, pos);
|
||||
if char == "@" then
|
||||
if s_sub(path, pos + 1, pos + 1) == "{" then
|
||||
return self.attr[s_gsub(s_sub(path, pos+2), "}", "\1", 1)];
|
||||
end
|
||||
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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue