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

* src/ejabberd_c2s.erl: We should allow use of bare resource in from by the client (partially revert r1727) (EJAB-812)

SVN Revision: 1759
This commit is contained in:
Mickaël Rémond 2008-12-28 12:15:51 +00:00
parent 1944aa097f
commit 707aa4fb8c
2 changed files with 31 additions and 13 deletions

View File

@ -1,3 +1,8 @@
2008-12-28 Mickael Remond <mremond@process-one.net>
* src/ejabberd_c2s.erl: We should allow use of bare resource in from by
the client (partially revert r1727) (EJAB-812).
2008-12-26 Badlop <badlop@process-one.net>
* src/web/ejabberd_web_admin.erl: Show in ejabberd Web Admin the

View File

@ -1983,17 +1983,30 @@ is_ip_blacklisted({IP,_Port}) ->
check_from(El, FromJID) ->
case xml:get_tag_attr("from", El) of
false ->
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) ->
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 ->
%% 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
%% any good reason for now not to do it on
%% 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'