Browse Source

updates #493

Compare bare JID of from attr in roster update. @teseo's fix was too specific
and tailored for a misbehaving server (servers shouldn't be sending from the
full JID in a roster push).
JC Brand 9 years ago
parent
commit
ea701f3865
3 changed files with 9 additions and 5 deletions
  1. 5 3
      converse.js
  2. 2 1
      docs/CHANGES.rst
  3. 2 1
      spec/protocol.js

+ 5 - 3
converse.js

@@ -4451,8 +4451,11 @@
                  */
                 var id = iq.getAttribute('id');
                 var from = iq.getAttribute('from');
-                if (from && from !== "" && from !== converse.connection.jid) {
+                if (from && from !== "" && Strophe.getBareJidFromJid(from) !== converse.bare_jid) {
                     // Receiving client MUST ignore stanza unless it has no from or from = user's bare JID.
+                    // XXX: Some naughty servers apparently send from a full
+                    // JID so we need to explicitly compare bare jids here.
+                    // https://github.com/jcbrand/converse.js/issues/493
                     converse.connection.send(
                         $iq({type: 'error', id: id, from: converse.connection.jid})
                             .c('error', {'type': 'cancel'})
@@ -4466,8 +4469,7 @@
                 }.bind(this));
 
                 converse.emit('rosterPush', iq);
-
-		return true;
+                return true;
             },
 
             fetchFromServer: function (callback, errback) {

+ 2 - 1
docs/CHANGES.rst

@@ -5,7 +5,8 @@ Changelog
 ------------------
 
 * #459 Wrong datatype passed to converse.chatboxes.getChatBox. [hobblegobber, jcbrand]
-* #493 Refactor previous bugfix and now an event is emitted when a roster push event from server happens. [teseo]
+* #493 Roster push fix [jcbrand]
+* #403 emit an event ``rosterPush`` when a roster push happens [teseo]
 * #502. Chat room not opened in non_amd version. [rjanbiah]
 * #505 Typo caused [object Object] in room info [gromiak]
 * #508 "Is typing" doesn't automatically disappear [jcbrand]

+ 2 - 1
spec/protocol.js

@@ -195,7 +195,8 @@
                     *  </iq>
                     */
                     spyOn(converse.roster, "updateContact").andCallThrough();
-                    stanza = $iq({'type': 'set'}).c('query', {'xmlns': 'jabber:iq:roster'})
+                    stanza = $iq({'type': 'set', 'from': 'dummy@localhost'})
+                        .c('query', {'xmlns': 'jabber:iq:roster'})
                         .c('item', {
                             'jid': 'contact@example.org',
                             'subscription': 'none',