diff options
Diffstat (limited to 'src/idna.erl')
-rw-r--r-- | src/idna.erl | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/idna.erl b/src/idna.erl index 5acf660e6..23e13deb3 100644 --- a/src/idna.erl +++ b/src/idna.erl @@ -9,7 +9,7 @@ -module(idna). -author('alexey@sevcom.net'). -%-compile(export_all). +%%-compile(export_all). -export([domain_utf8_to_ascii/1, domain_ucs2_to_ascii/1]). @@ -26,11 +26,11 @@ utf8_to_ucs2([C | S], R) when C < 16#80 -> utf8_to_ucs2(S, [C | R]); utf8_to_ucs2([C1, C2 | S], R) when C1 < 16#E0 -> utf8_to_ucs2(S, [((C1 band 16#1F) bsl 6) bor - (C2 band 16#3F) | R]); + (C2 band 16#3F) | R]); utf8_to_ucs2([C1, C2, C3 | S], R) when C1 < 16#F0 -> utf8_to_ucs2(S, [((C1 band 16#0F) bsl 12) bor - ((C2 band 16#3F) bsl 6) bor - (C3 band 16#3F) | R]). + ((C2 band 16#3F) bsl 6) bor + (C3 band 16#3F) | R]). domain_ucs2_to_ascii(Domain) -> @@ -49,15 +49,15 @@ domain_ucs2_to_ascii1(Domain) -> string:strip(lists:flatmap(fun(P) -> [$. | P] end, ASCIIParts), left, $.). -% Domain names are already nameprep'ed in ejabberd, so we skiping this step +%% Domain names are already nameprep'ed in ejabberd, so we skiping this step to_ascii(Name) -> false = lists:any( fun(C) when - ( 0 =< C) and (C =< 16#2C) or - (16#2E =< C) and (C =< 16#2F) or - (16#3A =< C) and (C =< 16#40) or - (16#5B =< C) and (C =< 16#60) or - (16#7B =< C) and (C =< 16#7F) -> + ( 0 =< C) and (C =< 16#2C) or + (16#2E =< C) and (C =< 16#2F) or + (16#3A =< C) and (C =< 16#40) or + (16#5B =< C) and (C =< 16#60) or + (16#7B =< C) and (C =< 16#7F) -> true; (_) -> false @@ -101,9 +101,9 @@ punycode_encode(Input) -> B = length(Basic), SNonBasic = lists:usort(NonBasic), Output1 = if - B > 0 -> Basic ++ "-"; - true -> "" - end, + B > 0 -> Basic ++ "-"; + true -> "" + end, Output2 = punycode_encode1(Input, SNonBasic, B, B, L, N, Delta, Bias, ""), Output1 ++ Output2. @@ -111,7 +111,7 @@ punycode_encode(Input) -> punycode_encode1(Input, [M | SNonBasic], B, H, L, N, Delta, Bias, Out) when H < L -> Delta1 = Delta + (M - N) * (H + 1), - % let n = m + % let n = m {NewDelta, NewBias, NewH, NewOut} = lists:foldl( fun(C, {ADelta, ABias, AH, AOut}) -> @@ -129,7 +129,7 @@ punycode_encode1(Input, [M | SNonBasic], B, H, L, N, Delta, Bias, Out) punycode_encode1( Input, SNonBasic, B, NewH, L, M + 1, NewDelta + 1, NewBias, NewOut); -punycode_encode1(Input, SNonBasic, B, H, L, N, Delta, Bias, Out) -> +punycode_encode1(_Input, _SNonBasic, _B, _H, _L, _N, _Delta, _Bias, Out) -> lists:reverse(Out). @@ -167,7 +167,7 @@ adapt1(Delta, K) -> true -> K + (((?BASE - ?TMIN + 1) * Delta) div (Delta + ?SKEW)) end. - + codepoint(C) -> if |