]> granicus.if.org Git - ejabberd/commitdiff
Check password with jid:resourceprep when registering account (#996)
authorBadlop <badlop@process-one.net>
Tue, 14 Jun 2016 21:35:47 +0000 (23:35 +0200)
committerBadlop <badlop@process-one.net>
Tue, 14 Jun 2016 21:35:47 +0000 (23:35 +0200)
src/mod_register.erl

index 27e484e852ae406d39ce475dce57f55bedf47337..73a999c3588dbd9eb329ceec54f9bf48e8ad770d 100644 (file)
@@ -386,6 +386,10 @@ try_set_password(User, Server, Password, IQ, SubEl,
                IQ#iq{type = error,
                      sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]}
          end;
+      error_preparing_password ->
+         ErrText = <<"The password contains unacceptable characters">>,
+         IQ#iq{type = error,
+               sub_el = [SubEl, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText)]};
       false ->
          ErrText = <<"The password is too weak">>,
          IQ#iq{type = error,
@@ -440,6 +444,10 @@ try_register(User, Server, Password, SourceRaw, Lang) ->
                                        {error, ?ERR_INTERNAL_SERVER_ERROR}
                                  end
                            end;
+                       error_preparing_password ->
+                           remove_timeout(Source),
+                           ErrText = <<"The password contains unacceptable characters">>,
+                           {error, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText)};
                        false ->
                            remove_timeout(Source),
                            ErrText = <<"The password is too weak">>,
@@ -636,6 +644,14 @@ process_xdata_submit(El) ->
     end.
 
 is_strong_password(Server, Password) ->
+    case jid:resourceprep(Password) of
+       PP when is_binary(PP) ->
+           is_strong_password2(Server, Password);
+       error ->
+           error_preparing_password
+    end.
+
+is_strong_password2(Server, Password) ->
     LServer = jid:nameprep(Server),
     case gen_mod:get_module_opt(LServer, ?MODULE, password_strength,
                                 fun(N) when is_number(N), N>=0 -> N end,