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

Normalize hostname when processing host_config

This commit is contained in:
Paweł Chmielowski 2018-12-06 15:12:23 +01:00
parent 157e9c04f6
commit 3b1c0dc27f

View File

@ -500,7 +500,8 @@ get_config_option_key(Name, Val) ->
maps_to_lists(IMap) ->
maps:fold(fun(Name, Map, Res) when Name == host_config orelse Name == append_host_config ->
[{Name, [{Host, maps_to_lists(SMap)} || {Host,SMap} <- maps:values(Map)]} | Res];
[{Name, [{jid:nameprep(Host), maps_to_lists(SMap)} ||
{Host,SMap} <- maps:values(Map)]} | Res];
(Name, Map, Res) when is_map(Map) ->
[{Name, maps:values(Map)} | Res];
(Name, Val, Res) ->
@ -513,8 +514,9 @@ merge_configs(Terms, ResMap) ->
New = lists:foldl(fun(SVal, OMap) ->
NVal = if Name == host_config orelse Name == append_host_config ->
{Host, Opts} = SVal,
{_, SubMap} = maps:get(Host, OMap, {Host, #{}}),
{Host, merge_configs(Opts, SubMap)};
HostNP = jid:nameprep(Host),
{_, SubMap} = maps:get(HostNP, OMap, {HostNP, #{}}),
{HostNP, merge_configs(Opts, SubMap)};
true ->
SVal
end,