Bug 954350 - Problems when connecting to irc.umich.edu (requires ident or non-standard captcha). r=aleth
authorPatrick Cloke <clokep@gmail.com>
Wed, 24 Sep 2014 08:54:43 -0400
changeset 16879 2505dd51816363f1c54243e90156d1a7889b2295
parent 16878 a0b9e4da8ee25a5754fa9e4b308510b89a316481
child 16880 d142f53ff7abf95d303cd26f6e48aa9668a56536
push id10502
push userclokep@gmail.com
push dateTue, 14 Oct 2014 16:12:49 +0000
treeherdercomm-central@82f288fa2c38 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaleth
bugs954350
Bug 954350 - Problems when connecting to irc.umich.edu (requires ident or non-standard captcha). r=aleth
chat/modules/imThemes.jsm
chat/protocols/irc/ircNonStandard.jsm
chat/themes/conv.css
--- a/chat/modules/imThemes.jsm
+++ b/chat/modules/imThemes.jsm
@@ -376,16 +376,18 @@ const statusMessageReplacements = {
     if (aMsg.containsNick)
       msgClass.push("nick");
     if (aMsg.error)
       msgClass.push("error");
     if (aMsg.delayed)
       msgClass.push("delayed");
     if (aMsg.notification)
       msgClass.push("notification");
+    if (aMsg.noFormat)
+      msgClass.push("monospaced");
 
     return msgClass.join(" ");
   }
 };
 
 function formatSender(aName)
   "<span class=\"ib-sender\">" + TXTToHTML(aName) + "</span>";
 const messageReplacements = {
--- a/chat/protocols/irc/ircNonStandard.jsm
+++ b/chat/protocols/irc/ircNonStandard.jsm
@@ -22,20 +22,37 @@ Cu.import("resource:///modules/ircUtils.
 var ircNonStandard = {
   name: "Non-Standard IRC Extensions",
   priority: ircHandlers.DEFAULT_PRIORITY + 1,
   isEnabled: function() true,
 
   commands: {
     "NOTICE": function(aMessage) {
       // NOTICE <msgtarget> <text>
+
+      // Try to avoid the stupid case where the user's nick is AUTH. If this
+      // happens, it is ambiguous if it is an AUTH message or a NOTICE to the
+      // user. Generally AUTH messages start with ***, but this could pretty
+      // easily be faked.
+      let isAuth = aMessage.params[0] == "AUTH" &&
+                   aMessage.params[1].startsWith("***");
+
+      // Some servers , e.g. irc.umich.edu, use NOTICE before connection to give
+      // directions to users.
+      if (!this.connected && !isAuth) {
+        this.getConversation(aMessage.servername)
+            .writeMessage(aMessage.servername, aMessage.params[1],
+                          {incoming: true});
+        return true;
+      }
+
       // If we receive a ZNC error message requesting a password, the
       // serverPassword preference was not set by the user. Attempt to log into
       // ZNC using the account password.
-      if (aMessage.params[0] != "AUTH" ||
+      if (!isAuth ||
           aMessage.params[1] != "*** You need to send your password. Try /quote PASS <username>:<password>")
         return false;
 
       if (this.imAccount.password) {
         // Send the password now, if it is available.
         this.shouldAuthenticate = false;
         this.sendMessage("PASS", this.imAccount.password,
                          "PASS <password not logged>");
@@ -132,11 +149,19 @@ var ircNonStandard = {
     "499": function(aMessage) { // ERR_CHANOWNPRIVNEEDED (Unreal)
       // <channel> :You're not the channel owner (status +q is needed)
       return conversationErrorMessage(this, aMessage, "error.notChannelOwner");
     },
 
     "671": function(aMessage) { // RPL_WHOISSECURE (Unreal & Charybdis)
       // <nick> :is using a Secure connection
       return this.setWhois(aMessage.params[1], {secure: true});
+    },
+
+    "998": function(aMessage) {
+      // irc.umich.edu shows an ASCII captcha that must be typed in by the user.
+      this.getConversation(aMessage.servername)
+          .writeMessage(aMessage.servername, aMessage.params[1],
+                        {incoming: true, noFormat: true});
+      return true;
     }
   }
 };
--- a/chat/themes/conv.css
+++ b/chat/themes/conv.css
@@ -40,8 +40,12 @@
 
 .ib-nick {
   font-weight: bold;
 }
 
 .ib-nick[left] {
   color: grey;
 }
+
+.monospaced {
+  font-family: monospace;
+}