25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Don't send error stanza as reply to error stanza (EJAB-930)

This commit is contained in:
Badlop 2010-04-20 20:31:42 +02:00
parent 2d375e0429
commit 2ff291899d
3 changed files with 14 additions and 2 deletions

View File

@ -31,6 +31,7 @@
%% API
-export([route/3,
route_error/4,
register_route/1,
register_route/2,
register_routes/1,
@ -72,6 +73,17 @@ route(From, To, Packet) ->
ok
end.
%% Route the error packet only if the originating packet is not an error itself.
%% RFC3920 9.3.1
route_error(From, To, ErrPacket, OrigPacket) ->
{xmlelement, _Name, Attrs, _Els} = OrigPacket,
case "error" == xml:get_attr_s("type", Attrs) of
false ->
route(From, To, ErrPacket);
true ->
ok
end.
register_route(Domain) ->
register_route(Domain, undefined).

View File

@ -351,7 +351,7 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
send_text(StateData, Text);
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_NOT_ALLOWED),
ejabberd_router:route(To, From, Err)
ejabberd_router:route_error(To, From, Err, Packet)
end,
{next_state, StateName, StateData}.

View File

@ -336,7 +336,7 @@ do_route(Host, ServerHost, Access, HistorySize, RoomShaper,
ErrText = "Access denied by service policy",
Err = jlib:make_error_reply(Packet,
?ERRT_FORBIDDEN(Lang, ErrText)),
ejabberd_router:route(To, From, Err)
ejabberd_router:route_error(To, From, Err, Packet)
end.