Skip to content

Commit

Permalink
only allow different "from"s if "to" was empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordin committed Feb 3, 2014
1 parent 4d76d8b commit 42340f5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1951,20 +1951,25 @@ Strophe.Connection.prototype = {
}

var expectedFrom = elem.getAttribute("to");
if (expectedFrom === null) {
expectedFrom = Strophe.getBareJidFromJid(this.jid);
var domain = this.domain;
var fulljid = this.jid;
}
var fulljid = this.jid;

var handler = this.addHandler(function (stanza) {
// remove timeout handler if there is one
if (timeoutHandler) {
that.deleteTimedHandler(timeoutHandler);
}

var acceptable = false;
var from = stanza.getAttribute("from");
if (from !== expectedFrom && from !== domain && from !== fulljid) {
if (from === expectedFrom ||
(expectedFrom === null &&
(from === Strophe.getBareJidFromJid(fulljid) ||
from === Strophe.getDomainFromJid(fulljid) ||
from === fulljid))) {
acceptable = true;
}

if (!acceptable) {
throw {
name: "StropheError",
message: "Got answer to IQ from wrong jid:" + from +
Expand Down

0 comments on commit 42340f5

Please sign in to comment.