25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

Fix validation of user field in get_user_subscriptions command

I made it test for valid muc room, instead of just valid username.

This should fix issue #4197
This commit is contained in:
Paweł Chmielowski 2024-04-11 12:15:30 +02:00
parent 426e33d3a6
commit 61ad808d26

View File

@ -564,7 +564,7 @@ get_user_rooms(User, Server) ->
end, ejabberd_option:hosts()).
get_user_subscriptions(User, Server) ->
User2 = validate_muc(User, <<"user">>),
User2 = validate_user(User, <<"user">>),
Server2 = validate_host(Server, <<"host">>),
Services = find_services(global),
UserJid = jid:make(User2, Server2),
@ -1582,6 +1582,15 @@ validate_host(Name, ArgName) ->
end
end.
-spec validate_user(Name :: binary(), ArgName::binary()) -> binary().
validate_user(Name, ArgName) ->
case jid:nodeprep(Name) of
error ->
throw({error, <<"Invalid value of '",ArgName/binary,"'">>});
Name2 ->
Name2
end.
-spec validate_muc(Name :: binary(), ArgName::binary()) -> binary().
validate_muc(Name, ArgName) ->
case jid:nameprep(Name) of