aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2017-10-31 12:06:40 +0100
committerChristophe Romain <christophe.romain@process-one.net>2017-10-31 12:06:40 +0100
commite24e05c6af3df3785478290755a9fb88094e5a39 (patch)
treedda2b3d1212b8e34dadd322c518ac15cf8505ef9
parentAdd missing type conversion from 675cc3e (diff)
Enforce module_name/1
-rw-r--r--src/ejabberd.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ejabberd.erl b/src/ejabberd.erl
index 9022c5d22..7e1a1106c 100644
--- a/src/ejabberd.erl
+++ b/src/ejabberd.erl
@@ -157,11 +157,20 @@ module_name([Dir, _, <<H,_/binary>> | _] = Mod) when H >= 65, H =< 90 ->
end,
misc:binary_to_atom(<<Prefix/binary, Module/binary>>);
module_name([<<"ejabberd">> | _] = Mod) ->
- misc:binary_to_atom(str:join(Mod,$_));
+ Module = str:join([erlang_name(M) || M<-Mod], $_),
+ misc:binary_to_atom(Module);
module_name(Mod) when is_list(Mod) ->
- misc:binary_to_atom(str:join(tl(Mod),$_)).
+ Module = str:join([erlang_name(M) || M<-tl(Mod)], $_),
+ misc:binary_to_atom(Module).
+elixir_name(Atom) when is_atom(Atom) ->
+ elixir_name(misc:atom_to_binary(Atom));
elixir_name(<<H,T/binary>>) when H >= 65, H =< 90 ->
<<H, T/binary>>;
elixir_name(<<H,T/binary>>) ->
<<(H-32), T/binary>>.
+
+erlang_name(Atom) when is_atom(Atom) ->
+ misc:atom_to_binary(Atom);
+erlang_name(Bin) when is_binary(Bin) ->
+ Bin.