Fix a fatal bug due to IRC case-smashing.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 2 Oct 2012 22:59:20 +0000 (18:59 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 2 Oct 2012 22:59:20 +0000 (18:59 -0400)
irkerd

diff --git a/irkerd b/irkerd
index 2b5e21ac7abc5c9da38923d43191f3f3cbbf6a80..04b3ef6a9185415a0e70bb0045e39b8a73a2caa2 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -141,7 +141,11 @@ class Connection:
     def handle_kick(self, outof):
         "We've been kicked."
         self.status = "handshaking"
-        self.channels_joined.remove(outof)
+        try:
+            self.channels_joined.remove(outof)
+        except ValueError:
+            self.irker.logerr("kicked by %s from %s that's not joined" \
+                              % (self.servername, outof))
         qcopy = []
         while not self.queue.empty():
             (channel, message) = self.queue.get()
@@ -255,7 +259,12 @@ class Target():
         if not ircport:
             ircport = 6667
         self.servername = irchost
-        self.channel = parsed.path.lstrip('/')
+        # IRC channel names are case-insensitive.  If we don't smash
+        # case here we may run into problems later. There was a bug
+        # observed on irc.rizon.net where an irkerd user specified #Channel,
+        # got kicked, and irkerd crashed because the server returned
+        # "#channel" in the notification that our kick handler saw.
+        self.channel = parsed.path.lstrip('/').lower()
         if self.channel and self.channel[0] not in "#&+":
             self.channel = "#" + self.channel
         self.port = int(ircport)