mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 09:49:18 +02:00
mod_private: Don't crash on invalid bookmarks
Catch failures while decoding the conference bookmark element.
This commit is contained in:
parent
a19ab9f4e3
commit
eca3204e82
1 changed files with 13 additions and 10 deletions
|
@ -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(_) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue