diff options
author | Paweł Chmielowski <pchmielowski@process-one.net> | 2020-01-22 12:52:30 +0100 |
---|---|---|
committer | Paweł Chmielowski <pchmielowski@process-one.net> | 2020-01-22 12:55:27 +0100 |
commit | 75094df25eb739931237c7c2642334b270120443 (patch) | |
tree | c7775c07655b51b4e29f2f5b66a30e3570f29389 /src | |
parent | Fix 20.01 changelog (diff) |
Do not use ~ts format in string that are put in xmpp payload
We are expecting utf8 data here, and using that flag will convert those
to unicode codepoints, which aren't handled properly later.
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_admin.erl | 10 | ||||
-rw-r--r-- | src/ejabberd_captcha.erl | 4 | ||||
-rw-r--r-- | src/ejabberd_xmlrpc.erl | 2 | ||||
-rw-r--r-- | src/mod_fail2ban.erl | 4 | ||||
-rw-r--r-- | src/mod_muc_admin.erl | 2 | ||||
-rw-r--r-- | src/mod_muc_room.erl | 22 | ||||
-rw-r--r-- | src/mod_multicast.erl | 2 | ||||
-rw-r--r-- | src/mod_register.erl | 6 | ||||
-rw-r--r-- | src/mod_s2s_dialback.erl | 4 | ||||
-rw-r--r-- | src/pubsub_subscription.erl | 8 | ||||
-rw-r--r-- | src/pubsub_subscription_sql.erl | 8 |
11 files changed, 36 insertions, 36 deletions
diff --git a/src/ejabberd_admin.erl b/src/ejabberd_admin.erl index 95f9000b1..91072c5dd 100644 --- a/src/ejabberd_admin.erl +++ b/src/ejabberd_admin.erl @@ -409,7 +409,7 @@ status() -> false -> {ejabberd_not_running, "ejabberd is not running in that node."}; {value, {_, _, Version}} -> - {ok, io_lib:format("ejabberd ~ts is running in that node", [Version])} + {ok, io_lib:format("ejabberd ~s is running in that node", [Version])} end, {Is_running, String1 ++ String2}. @@ -472,7 +472,7 @@ stop_kindly(DelaySeconds, AnnouncementTextString) -> ok. send_service_message_all_mucs(Subject, AnnouncementText) -> - Message = str:format("~ts~n~ts", [Subject, AnnouncementText]), + Message = str:format("~s~n~s", [Subject, AnnouncementText]), lists:foreach( fun(ServerHost) -> MUCHosts = gen_mod:get_module_opt_hosts(ServerHost, mod_muc), @@ -516,12 +516,12 @@ register(User, Host, Password) -> true -> case ejabberd_auth:try_register(User, Host, Password) of ok -> - {ok, io_lib:format("User ~ts@~ts successfully registered", [User, Host])}; + {ok, io_lib:format("User ~s@~s successfully registered", [User, Host])}; {error, exists} -> - Msg = io_lib:format("User ~ts@~ts already registered", [User, Host]), + Msg = io_lib:format("User ~s@~s already registered", [User, Host]), {error, conflict, 10090, Msg}; {error, Reason} -> - String = io_lib:format("Can't register user ~ts@~ts at node ~p: ~ts", + String = io_lib:format("Can't register user ~s@~s at node ~p: ~s", [User, Host, node(), mod_register:format_error(Reason)]), {error, cannot_register, 10001, String} diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index 8190e6931..6e1242e9c 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -94,8 +94,8 @@ create_captcha(SID, From, To, Lang, Limiter, Args) -> Lang, [challenge]), X = #xdata{type = form, fields = Fs}, Captcha = #xcaptcha{xdata = X}, - BodyString = {?T("Your subscription request and/or messages to ~ts have been blocked. " - "To unblock your subscription request, visit ~ts"), [JID, get_url(Id)]}, + BodyString = {?T("Your subscription request and/or messages to ~s have been blocked. " + "To unblock your subscription request, visit ~s"), [JID, get_url(Id)]}, Body = xmpp:mk_text(BodyString, Lang), OOB = #oob_x{url = get_url(Id)}, Hint = #hint{type = 'no-store'}, diff --git a/src/ejabberd_xmlrpc.erl b/src/ejabberd_xmlrpc.erl index 9b4b119b6..f341913bf 100644 --- a/src/ejabberd_xmlrpc.erl +++ b/src/ejabberd_xmlrpc.erl @@ -375,7 +375,7 @@ format_result(Code, {Name, rescode}) -> format_result({Code, Text}, {Name, restuple}) -> {struct, [{Name, make_status(Code)}, - {text, io_lib:format("~ts", [Text])}]}; + {text, io_lib:format("~s", [Text])}]}; format_result(Elements, {Name, {list, ElementsDef}}) -> FormattedList = lists:map(fun (Element) -> format_result(Element, ElementsDef) diff --git a/src/mod_fail2ban.erl b/src/mod_fail2ban.erl index 6492501df..17129ffd9 100644 --- a/src/mod_fail2ban.erl +++ b/src/mod_fail2ban.erl @@ -217,8 +217,8 @@ log_and_disconnect(#{ip := {Addr, _}, lang := Lang} = State, Attempts, UnbanTS) UnbanDate = format_date( calendar:now_to_universal_time(msec_to_now(UnbanTS))), Format = ?T("Too many (~p) failed authentications " - "from this IP address (~ts). The address " - "will be unblocked at ~ts UTC"), + "from this IP address (~s). The address " + "will be unblocked at ~s UTC"), Args = [Attempts, IP, UnbanDate], ?WARNING_MSG("Connection attempt from blacklisted IP ~ts: ~ts", [IP, io_lib:fwrite(Format, Args)]), diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 9a3ed7602..34bc79b0a 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -886,7 +886,7 @@ act_on_rooms(Method, Action, Rooms) -> act_on_room(Method, destroy, {N, H, SH, Pid}) -> Message = iolist_to_binary(io_lib:format( - <<"Room destroyed by rooms_~ts_destroy.">>, [Method])), + <<"Room destroyed by rooms_~s_destroy.">>, [Method])), mod_muc_room:destroy(Pid, Message), mod_muc:room_destroyed(H, N, Pid, SH), mod_muc:forget_room(SH, H, N); diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index ea2b069d7..963a5b9a2 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -371,8 +371,8 @@ normal_state({route, <<"">>, case is_user_online(From, StateData) of true -> ErrorText = ?T("It is not allowed to send error messages to the" - " room. The participant (~ts) has sent an error " - "message (~ts) and got kicked from the room"), + " room. The participant (~s) has sent an error " + "message (~s) and got kicked from the room"), NewState = expulse_participant(Packet, From, StateData, translate:translate(Lang, ErrorText)), @@ -517,8 +517,8 @@ normal_state({route, ToNick, {expulse_sender, Reason} -> ?DEBUG(Reason, []), ErrorText = ?T("It is not allowed to send error messages to the" - " room. The participant (~ts) has sent an error " - "message (~ts) and got kicked from the room"), + " room. The participant (~s) has sent an error " + "message (~s) and got kicked from the room"), NewState = expulse_participant(Packet, From, StateData, translate:translate(Lang, ErrorText)), {next_state, normal_state, NewState}; @@ -1291,8 +1291,8 @@ do_process_presence(Nick, #presence{from = From, type = unavailable} = Packet, do_process_presence(_Nick, #presence{from = From, type = error, lang = Lang} = Packet, StateData) -> ErrorText = ?T("It is not allowed to send error messages to the" - " room. The participant (~ts) has sent an error " - "message (~ts) and got kicked from the room"), + " room. The participant (~s) has sent an error " + "message (~s) and got kicked from the room"), expulse_participant(Packet, From, StateData, translate:translate(Lang, ErrorText)). @@ -1383,7 +1383,7 @@ decide_fate_message(#message{type = error} = Msg, %% If this is an error stanza and its condition matches a criteria true -> Reason = str:format("This participant is considered a ghost " - "and is expulsed: ~ts", + "and is expulsed: ~s", [jid:encode(From)]), {expulse_sender, Reason}; false -> continue_delivery @@ -2991,7 +2991,7 @@ find_changed_items(UJID, UAffiliation, URole, Nick /= <<"">> -> case find_jids_by_nick(Nick, StateData) of [] -> - ErrText = {?T("Nickname ~ts does not exist in the room"), + ErrText = {?T("Nickname ~s does not exist in the room"), [Nick]}, throw({error, xmpp:err_not_acceptable(ErrText, Lang)}); JIDList -> @@ -3486,7 +3486,7 @@ get_config(Lang, StateData, From) -> Config = StateData#state.config, MaxUsersRoom = get_max_users(StateData), Title = str:format( - translate:translate(Lang, ?T("Configuration of room ~ts")), + translate:translate(Lang, ?T("Configuration of room ~s")), [jid:encode(StateData#state.jid)]), Fs = [{roomname, Config#config.title}, {roomdesc, Config#config.description}, @@ -3629,7 +3629,7 @@ set_config(Opts, Config, ServerHost, Lang) -> {0, undefined} -> ?ERROR_MSG("set_room_option hook failed for " "option '~ts' with value ~p", [O, V]), - Txt = {?T("Failed to process option '~ts'"), [O]}, + Txt = {?T("Failed to process option '~s'"), [O]}, {error, xmpp:err_internal_server_error(Txt, Lang)}; {Pos, Val} -> setelement(Pos, C, Val) @@ -4463,7 +4463,7 @@ route_invitation(From, Pkt, Invitation, Lang, StateData) -> [io_lib:format( translate:translate( Lang, - ?T("~ts invites you to the room ~ts")), + ?T("~s invites you to the room ~s")), [jid:encode(From), jid:encode({StateData#state.room, StateData#state.host, <<"">>})]), case (StateData#state.config)#config.password_protected of diff --git a/src/mod_multicast.erl b/src/mod_multicast.erl index f55d21959..a6918fe23 100644 --- a/src/mod_multicast.erl +++ b/src/mod_multicast.erl @@ -495,7 +495,7 @@ report_not_jid(From, Packet, Dests) -> || Dest <- Dests], [route_error( xmpp:set_from_to(Packet, From, From), jid_malformed, - str:format(?T("This service can not process the address: ~ts"), [D])) + str:format(?T("This service can not process the address: ~s"), [D])) || D <- Dests2]. %%%------------------------- diff --git a/src/mod_register.erl b/src/mod_register.erl index 2a28737b0..545fb7d85 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -223,7 +223,7 @@ process_iq(#iq{type = get, from = From, to = To, id = ID, lang = Lang} = IQ, "with this server")), URL = mod_register_opt:redirect_url(Server), if (URL /= undefined) and not IsRegistered -> - Txt = translate:translate(Lang, ?T("To register, visit ~ts")), + Txt = translate:translate(Lang, ?T("To register, visit ~s")), Desc = str:format(Txt, [URL]), xmpp:make_iq_result( IQ, #register{instructions = Desc, @@ -419,8 +419,8 @@ send_registration_notifications(Mod, UJID, Source) -> [] -> ok; JIDs when is_list(JIDs) -> Body = - (str:format("[~ts] The account ~ts was registered from " - "IP address ~ts on node ~w using ~p.", + (str:format("[~s] The account ~s was registered from " + "IP address ~s on node ~w using ~p.", [get_time_string(), jid:encode(UJID), ejabberd_config:may_hide_data( diff --git a/src/mod_s2s_dialback.erl b/src/mod_s2s_dialback.erl index 85ccdbce0..a073fa543 100644 --- a/src/mod_s2s_dialback.erl +++ b/src/mod_s2s_dialback.erl @@ -277,7 +277,7 @@ s2s_out_packet(#{server := LServer, remote_server := RServer} = State, State2 = ejabberd_s2s_out:handle_auth_success(<<"dialback">>, State1), ejabberd_s2s_out:establish(State2); _ -> - Reason = str:format("Peer responded with error: ~ts", + Reason = str:format("Peer responded with error: ~s", [format_error(Result)]), ejabberd_s2s_out:handle_auth_failure( <<"dialback">>, {auth, Reason}, State1) @@ -337,7 +337,7 @@ send_db_result(State, #db_verify{from = From, to = To, From, <<"dialback">>, undefined, State1), ejabberd_s2s_in:establish(State2); _ -> - Reason = str:format("Verification failed: ~ts", + Reason = str:format("Verification failed: ~s", [format_error(Response)]), ejabberd_s2s_in:handle_auth_failure( From, <<"dialback">>, Reason, State1) diff --git a/src/pubsub_subscription.erl b/src/pubsub_subscription.erl index ac5137d2c..32a79aef5 100644 --- a/src/pubsub_subscription.erl +++ b/src/pubsub_subscription.erl @@ -206,13 +206,13 @@ val_xfield(digest_frequency = Opt, [Val]) -> case catch binary_to_integer(Val) of N when is_integer(N) -> N; _ -> - Txt = {?T("Value of '~ts' should be integer"), [Opt]}, + Txt = {?T("Value of '~s' should be integer"), [Opt]}, {error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())} end; val_xfield(expire = Opt, [Val]) -> try xmpp_util:decode_timestamp(Val) catch _:{bad_timestamp, _} -> - Txt = {?T("Value of '~ts' should be datetime string"), [Opt]}, + Txt = {?T("Value of '~s' should be datetime string"), [Opt]}, {error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())} end; val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val); @@ -224,7 +224,7 @@ val_xfield(subscription_depth = Opt, [Depth]) -> case catch binary_to_integer(Depth) of N when is_integer(N) -> N; _ -> - Txt = {?T("Value of '~ts' should be integer"), [Opt]}, + Txt = {?T("Value of '~s' should be integer"), [Opt]}, {error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())} end. @@ -234,7 +234,7 @@ xopt_to_bool(_, <<"1">>) -> true; xopt_to_bool(_, <<"false">>) -> false; xopt_to_bool(_, <<"true">>) -> true; xopt_to_bool(Option, _) -> - Txt = {?T("Value of '~ts' should be boolean"), [Option]}, + Txt = {?T("Value of '~s' should be boolean"), [Option]}, {error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())}. %% Return a field for an XForm for Key, with data filled in, if diff --git a/src/pubsub_subscription_sql.erl b/src/pubsub_subscription_sql.erl index 9419545df..af31008be 100644 --- a/src/pubsub_subscription_sql.erl +++ b/src/pubsub_subscription_sql.erl @@ -171,13 +171,13 @@ val_xfield(digest_frequency = Opt, [Val]) -> case catch binary_to_integer(Val) of N when is_integer(N) -> N; _ -> - Txt = {?T("Value of '~ts' should be integer"), [Opt]}, + Txt = {?T("Value of '~s' should be integer"), [Opt]}, {error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())} end; val_xfield(expire = Opt, [Val]) -> try xmpp_util:decode_timestamp(Val) catch _:{bad_timestamp, _} -> - Txt = {?T("Value of '~ts' should be datetime string"), [Opt]}, + Txt = {?T("Value of '~s' should be datetime string"), [Opt]}, {error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())} end; val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val); @@ -189,7 +189,7 @@ val_xfield(subscription_depth = Opt, [Depth]) -> case catch binary_to_integer(Depth) of N when is_integer(N) -> N; _ -> - Txt = {?T("Value of '~ts' should be integer"), [Opt]}, + Txt = {?T("Value of '~s' should be integer"), [Opt]}, {error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())} end. @@ -199,7 +199,7 @@ xopt_to_bool(_, <<"1">>) -> true; xopt_to_bool(_, <<"false">>) -> false; xopt_to_bool(_, <<"true">>) -> true; xopt_to_bool(Option, _) -> - Txt = {?T("Value of '~ts' should be boolean"), [Option]}, + Txt = {?T("Value of '~s' should be boolean"), [Option]}, {error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())}. %% Return a field for an XForm for Key, with data filled in, if |