aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_bookmarks.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-01-11 00:06:48 +0100
committerKim Alvefur <zash@zash.se>2022-01-11 00:06:48 +0100
commit2a0311098cedfd93ecf0f0a83b8bcc9066531d09 (patch)
tree7510dd324588c0e7db98b19d8ba484c1cf42d5a6 /plugins/mod_bookmarks.lua
parentba50691289cdca1eb574e3e6231ec27d50c2ce67 (diff)
downloadprosody-2a0311098cedfd93ecf0f0a83b8bcc9066531d09.tar.gz
prosody-2a0311098cedfd93ecf0f0a83b8bcc9066531d09.zip
mod_bookmarks: Fix traceback on attempt to convert invalid bookmark
Found by accidentally publishing {urn:xmpp:bookmarks:0}conference instead of :1 due to testing this earlier for the blocking. By the principle of garbage in, garbage out, just generate a bookmark from the item id / JID and carry on with a warning.
Diffstat (limited to 'plugins/mod_bookmarks.lua')
-rw-r--r--plugins/mod_bookmarks.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/mod_bookmarks.lua b/plugins/mod_bookmarks.lua
index 1e89053a..ad5f459e 100644
--- a/plugins/mod_bookmarks.lua
+++ b/plugins/mod_bookmarks.lua
@@ -41,16 +41,21 @@ local function generate_legacy_storage(items)
for _, item_id in ipairs(items) do
local item = items[item_id];
local bookmark = item:get_child("conference", namespace);
+ if not bookmark then
+ module:log("warn", "Invalid bookmark published: expected {%s}conference, got {%s}%s", namespace,
+
+ item.tags[1] and item.tags[1].attr.xmlns, item.tags[1] and item.tags[1].name);
+ end
local conference = st.stanza("conference", {
jid = item.attr.id,
- name = bookmark.attr.name,
- autojoin = bookmark.attr.autojoin,
+ name = bookmark and bookmark.attr.name,
+ autojoin = bookmark and bookmark.attr.autojoin,
});
- local nick = bookmark:get_child_text("nick");
+ local nick = bookmark and bookmark:get_child_text("nick");
if nick ~= nil then
conference:text_tag("nick", nick):up();
end
- local password = bookmark:get_child_text("password");
+ local password = bookmark and bookmark:get_child_text("password");
if password ~= nil then
conference:text_tag("password", password):up();
end