Skip to content

Commit

Permalink
Fix stream from verification
Browse files Browse the repository at this point in the history
https://datatracker.ietf.org/doc/html/rfc6120#section-8.1.2.1
1.  When a server receives an XML stanza from a connected client, the
       server MUST add a 'from' attribute to the stanza or override the
       'from' attribute specified by the client, where the value of the
       'from' attribute MUST be the full JID
       (<localpart@domainpart/resource>) determined by the server for
       the connected resource that generated the stanza (see
       Section 4.3.6), or the bare JID (<localpart@domainpart>) in the
       case of subscription-related presence stanzas (see [XMPP-IM]).
  • Loading branch information
NelsonVides committed Oct 3, 2022
1 parent 6f9302e commit cfae222
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/c2s/mongoose_c2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,15 @@ maybe_retry_state({wait_for_sasl_response, SaslState, Retries}) ->
verify_from(El, StateJid) ->
case exml_query:attr(El, <<"from">>) of
undefined -> true;
SJid ->
jid:are_equal(jid:from_binary(SJid), StateJid)
GJid ->
case jid:from_binary(GJid) of
error ->
false;
#jid{lresource = <<>>} = GivenJid ->
jid:are_bare_equal(GivenJid, StateJid);
#jid{} = GivenJid ->
jid:are_equal(GivenJid, StateJid)
end
end.

-spec handle_foreign_packet(c2s_data(), c2s_state(), exml:element()) -> fsm_res().
Expand Down

0 comments on commit cfae222

Please sign in to comment.