Bug 920801 - Port chat/ changes from Instantbird to comm-central - 6 - Bio 1900 - aPhotoNode.getElement(...) is null when connecting to LiveJournal, r=fqueze.
authorPatrick Cloke <clokep@gmail.com>
Wed, 25 Sep 2013 15:19:01 -0400
changeset 17242 1d7c27dcd3c08ce1115200b9a1da6a26d87068f0
parent 17241 4ee1299a54bd181bd93bf158dcd8c1e5a6c546be
child 17243 75e8768c941d7c8078c9483f37ed8dea47fbe0ef
push id1103
push usermbanner@mozilla.com
push dateTue, 18 Mar 2014 07:44:06 +0000
treeherdercomm-beta@50c6279a0af0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfqueze
bugs920801
Bug 920801 - Port chat/ changes from Instantbird to comm-central - 6 - Bio 1900 - aPhotoNode.getElement(...) is null when connecting to LiveJournal, r=fqueze.
chat/protocols/xmpp/xmpp.jsm
--- a/chat/protocols/xmpp/xmpp.jsm
+++ b/chat/protocols/xmpp/xmpp.jsm
@@ -437,17 +437,21 @@ const XMPPAccountBuddyPrototype = {
                                   Stanza.node("item", null,
                                               {jid: this.normalizedName,
                                                subscription: "remove"})));
     this._account._connection.sendStanza(s);
   },
 
   _photoHash: null,
   _saveIcon: function(aPhotoNode) {
-    let type = aPhotoNode.getElement(["TYPE"]).innerText;
+    // Some servers seem to send a photo node without a type declared.
+    let type = aPhotoNode.getElement(["TYPE"]);
+    if (!type)
+      return;
+    type = type.innerText;
     const kExt = {"image/gif": "gif", "image/jpeg": "jpg", "image/png": "png"};
     if (!kExt.hasOwnProperty(type))
       return;
 
     let data = aPhotoNode.getElement(["BINVAL"]).innerText;
     let content = atob(data.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
 
     // Store a sha1 hash of the photo we have just received.