Skip to content

Commit

Permalink
Fix validation of user field in get_user_subscriptions command
Browse files Browse the repository at this point in the history
I made it test for valid muc room, instead of just valid username.

This should fix issue #4197
  • Loading branch information
prefiks committed Apr 11, 2024
1 parent 426e33d commit 61ad808
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/mod_muc_admin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 61ad808

Please sign in to comment.