24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-16 22:05:29 +02:00

* src/ejabberd_c2s.erl: Bugfix in "from" attribute checking

SVN Revision: 1763
This commit is contained in:
Alexey Shchepin 2008-12-29 11:11:37 +00:00
parent 5a5ab955cb
commit df478a8e90
2 changed files with 21 additions and 19 deletions

View File

@ -1,3 +1,7 @@
2008-12-29 Alexey Shchepin <alexey@process-one.net>
* src/ejabberd_c2s.erl: Bugfix in "from" attribute checking
2008-12-29 Evgeniy Khramtsov <ekhramtsov@process-one.net>
* src/odbc/ejabberd_odbc.erl: Print meaningful error message when

View File

@ -1983,14 +1983,21 @@ is_ip_blacklisted({IP,_Port}) ->
check_from(El, FromJID) ->
case xml:get_tag_attr("from", El) of
false ->
jlib:replace_from(FromJID, El);
{value, JIDElString} ->
JIDEl = jlib:string_to_jid(JIDElString),
case JIDEl#jid.lresource of
"" ->
%% Matching JID: The stanza is ok
if JIDEl#jid.luser == FromJID#jid.luser andalso
JIDEl#jid.lserver == FromJID#jid.lserver ->
El;
{value, SJID} ->
JID = jlib:string_to_jid(SJID),
case JID of
error ->
'invalid-from';
#jid{} ->
if
(JID#jid.luser == FromJID#jid.luser) and
(JID#jid.lserver == FromJID#jid.lserver) and
(JID#jid.lresource == FromJID#jid.lresource) ->
El;
(JID#jid.luser == FromJID#jid.luser) and
(JID#jid.lserver == FromJID#jid.lserver) and
(JID#jid.lresource == "") ->
%% We force the resource on the from attribute in the packet.
%% This is strictly needed only for IQ (to
%% reply to the client), but I do not see
@ -1998,18 +2005,9 @@ check_from(El, FromJID) ->
%% all packets.
%% Need to be changed to support multiple
%% resource binding per connection.
jlib:replace_from(FromJID, El);
true ->
'invalid-from'
end;
_ ->
%% Matching JID: The stanza is ok
if JIDEl#jid.luser == FromJID#jid.luser andalso
JIDEl#jid.lserver == FromJID#jid.lserver andalso
JIDEl#jid.lresource == FromJID#jid.lresource ->
El;
true ->
'invalid-from'
true ->
'invalid-from'
end
end
end.