Skip to content

Commit

Permalink
Merge pull request #350 from centralway/remove-idna-module-and-use-de…
Browse files Browse the repository at this point in the history
…pendency-wip

Use erlang-idna from hackney instead of own impl.
  • Loading branch information
michalwski committed Jan 15, 2015
2 parents 5ade6c5 + 92840ed commit b81c610
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 223 deletions.
16 changes: 15 additions & 1 deletion apps/ejabberd/src/ejabberd_s2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
dirty_get_connections/0,
allow_host/2,
incoming_s2s_number/0,
outgoing_s2s_number/0
outgoing_s2s_number/0,
domain_utf8_to_ascii/1
]).

%% gen_server callbacks
Expand Down Expand Up @@ -463,6 +464,19 @@ parent_domains(<<_, Rest/binary>>, Acc) ->
send_element(Pid, El) ->
Pid ! {send_element, El}.

%%--------------------------------------------------------------------
%% Function: domain_utf8_to_ascii(Domain) -> binary() | false
%% Description: Converts a UTF-8 domain to ASCII (IDNA)
%% --------------------------------------------------------------------
-spec domain_utf8_to_ascii(binary() | string()) -> binary() | false.
domain_utf8_to_ascii(Domain) ->
case catch idna:utf8_to_ascii(Domain) of
{'EXIT', _} ->
false;
AsciiDomain ->
list_to_binary(AsciiDomain)
end.

%%%----------------------------------------------------------------------
%%% ejabberd commands

Expand Down
4 changes: 2 additions & 2 deletions apps/ejabberd/src/ejabberd_s2s_in.erl
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ wait_for_feature_request({xmlstreamelement, El}, StateData) ->
error ->
false;
_ ->
case idna:domain_utf8_to_ascii(AuthDomain) of
case ejabberd_s2s:domain_utf8_to_ascii(AuthDomain) of
false ->
false;
PCAuthDomain ->
Expand Down Expand Up @@ -757,7 +757,7 @@ get_cert_domains(Cert) ->
#jid{luser = <<"">>,
lserver = LD,
lresource = <<"">>} ->
case idna:domain_utf8_to_ascii(LD) of
case ejabberd_s2s:domain_utf8_to_ascii(LD) of
false ->
[];
PCLD ->
Expand Down
2 changes: 1 addition & 1 deletion apps/ejabberd/src/ejabberd_s2s_out.erl
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ open_socket(init, StateData) ->
StateData#state.new,
StateData#state.verify}]),
AddrList = get_predefined_addresses(StateData#state.server) ++
case idna:domain_utf8_to_ascii(StateData#state.server) of
case ejabberd_s2s:domain_utf8_to_ascii(StateData#state.server) of
false ->
[];
ASCIIAddr ->
Expand Down
218 changes: 0 additions & 218 deletions apps/ejabberd/src/idna.erl

This file was deleted.

1 change: 1 addition & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{mochijson2, ".*", {git, "git://github.com/bjnortier/mochijson2.git", {branch, "master"}}},
{alarms, ".*", {git, "git://github.com/chrzaszcz/alarms.git", {branch, "master"}}},
{fusco, ".*", {git, "git://github.com/esl/fusco.git", {branch, "master"}}},
{idna, ".*", {git, "git://github.com/benoitc/erlang-idna.git", {tag, "1.0.1"}}},

{seestar, ".*", {git, "git://github.com/iamaleksey/seestar.git", "83e8099b617fffe5af86d4c91d84ce3608accd25"}},

Expand Down
3 changes: 2 additions & 1 deletion rel/reltool.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ BaseAppsToInclude = AppsToRun ++
pa,
base16,
cuesport,
alarms],
alarms,
idna],


RemovedApps = [mysql,pgsql,redo,seestar,odbc],
Expand Down

0 comments on commit b81c610

Please sign in to comment.