Bug 842183 - Land in comm-central Instantbird's changes to chat/ - 5 - Bio 1814 - Fix ISUPPORT (Watch/Monitor), r=aleth.
authorPatrick Cloke <clokep@gmail.com>
Wed, 21 Nov 2012 11:02:59 -0500
changeset 11974 daad988db75ff4efbb1e12c4046e52ca00d5eaa1
parent 11973 ed567231bd4f3fd6d16fbcb1a809910e0692e539
child 11975 25e1726d6df85ec62b0d005b184cea2d96dfd752
push id8909
push userflorian@queze.net
push dateMon, 18 Feb 2013 14:55:18 +0000
treeherdercomm-central@dad38b5c0099 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaleth
bugs842183
Bug 842183 - Land in comm-central Instantbird's changes to chat/ - 5 - Bio 1814 - Fix ISUPPORT (Watch/Monitor), r=aleth.
chat/protocols/irc/ircISUPPORT.jsm
--- a/chat/protocols/irc/ircISUPPORT.jsm
+++ b/chat/protocols/irc/ircISUPPORT.jsm
@@ -15,56 +15,55 @@
 const EXPORTED_SYMBOLS = ["ircISUPPORT", "isupportBase"];
 
 const Cu = Components.utils;
 
 Cu.import("resource:///modules/ircHandlers.jsm");
 Cu.import("resource:///modules/ircUtils.jsm");
 
 /*
- * Parses a individual token from a ISUPPORT message of the form:
+ * Parses an ircMessage into an ISUPPORT message for each token of the form:
  *   <parameter>=<value> or -<value>
  * The isupport field is added to the message and it has the following fields:
  *   parameter  What is being configured by this ISUPPORT token.
  *   useDefault Whether this parameter should be reset to the default value, as
  *              defined by the RFC.
  *   value      The new value for the parameter.
  */
 function isupportMessage(aMessage, aToken) {
+  // Seperate the ISUPPORT parameters.
+  let tokens = aMessage.params.slice(1, -1);
+
   let message = aMessage;
   message.isupport = {};
-  message.isupport.useDefault = aToken[0] == "-";
 
-  let token = message.isupport.useDefault ? aToken.slice(1) : aToken;
-  [message.isupport.parameter, message.isupport.value] = token.split("=");
-
-  return message;
+  return tokens.map(function(aToken) {
+    let newMessage = JSON.parse(JSON.stringify(message));
+    newMessage.isupport.useDefault = aToken[0] == "-";
+    [newMessage.isupport.parameter, newMessage.isupport.value] =
+      (newMessage.isupport.useDefault ? aToken.slice(1) : aToken).split("=");
+    return newMessage;
+  });
 }
 
 var ircISUPPORT = {
   name: "ISUPPORT",
   // Slightly above default RFC 2812 priority.
   priority: ircHandlers.DEFAULT_PRIORITY + 10,
   isEnabled: function() true,
 
   commands: {
     // RPL_ISUPPORT
     // [-]<parameter>[=<value>] :are supported by this server
     "005": function(aMessage) {
-      if (!("ISUPPORT" in this))
-        this.ISUPPORT = {};
-
-      // Seperate the ISUPPORT parameters.
-      let tokens = aMessage.params.slice(1, -1);
+      let messages = isupportMessage(aMessage);
 
       let handled = true;
-      for each (let token in tokens) {
-        let message = isupportMessage(aMessage, token);
+      for each (let message in messages)
         handled &= ircHandlers.handleISUPPORTMessage(this, message);
-      }
 
       return handled;
     }
   }
 }
 
 function setSimpleNumber(aAccount, aField, aMessage, aDefaultValue) {
   let value =