1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 17:59:31 +02:00

mod_private: Don't crash on invalid bookmarks

Catch failures while decoding the conference bookmark element.
This commit is contained in:
Holger Weiss 2025-01-28 19:37:49 +01:00
parent a19ab9f4e3
commit eca3204e82

View file

@ -447,17 +447,20 @@ pubsub_delete_item(_, _, _, _, _) ->
-spec pubsub_item_to_storage_bookmark(#pubsub_item{}) -> {true, bookmark_conference()} | false. -spec pubsub_item_to_storage_bookmark(#pubsub_item{}) -> {true, bookmark_conference()} | false.
pubsub_item_to_storage_bookmark(#pubsub_item{itemid = {Id, _}, payload = [#xmlel{} = B | _]}) -> pubsub_item_to_storage_bookmark(#pubsub_item{itemid = {Id, _}, payload = [#xmlel{} = B | _]}) ->
case xmpp:decode(B) of try
#pep_bookmarks_conference{name = Name, autojoin = AutoJoin, nick = Nick, #pep_bookmarks_conference{name = Name, autojoin = AutoJoin, nick = Nick,
password = Password} -> password = Password} = xmpp:decode(B),
try jid:decode(Id) of #jid{} = Jid = jid:decode(Id),
#jid{} = Jid -> {true, #bookmark_conference{jid = Jid, name = Name,
{true, #bookmark_conference{jid = Jid, name = Name, autojoin = AutoJoin, nick = Nick, autojoin = AutoJoin, nick = Nick,
password = Password}} password = Password}}
catch _:_ -> catch
false _:{xmpp_codec, Why} ->
end; ?DEBUG("Failed to decode bookmark element (~ts): ~ts",
_ -> [Id, xmpp:format_error(Why)]),
false;
_:{bad_jid, _} ->
?DEBUG("Failed to decode bookmark ID (~ts)", [Id]),
false false
end; end;
pubsub_item_to_storage_bookmark(_) -> pubsub_item_to_storage_bookmark(_) ->