changeset 30699:adef21420870

Some fixes to IRC handling in purple-url-handler, mainly to fix https://bugzilla.redhat.com/show_bug.cgi?id=614426 I probably broke it horribly in the process, but given that it wasn't even verifying the account was an IRC account before it can't be much more broken now. can it?
author Stu Tomlinson <stu@nosnilmot.com>
date Tue, 20 Jul 2010 02:27:17 +0000
parents e874875a74a7
children b2b4af06a0b5
files libpurple/purple-url-handler
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/purple-url-handler	Mon Jul 19 18:25:47 2010 +0000
+++ b/libpurple/purple-url-handler	Tue Jul 20 02:27:17 2010 +0000
@@ -73,7 +73,8 @@
 def findaccount(protocolname, accountname="", matcher=None):
     if matcher:
         for account in cpurple.PurpleAccountsGetAll():
-            if accountname != "" and accountname != cpurple.PurpleAccountGetUsername(a):
+            if (protocolname != cpurple.PurpleAccountGetProtocolID(account)) or \
+               (accountname != "" and accountname != cpurple.PurpleAccountGetUsername(account)):
                 continue
             if matcher(account):
                 bring_account_online(account)
@@ -182,7 +183,7 @@
 
 def irc(uri):
     protocol = "prpl-irc"
-    match = re.match(r"^irc:(//([^/]*)/)?([^?]*)(\?(.*))?", uri)
+    match = re.match(r"^irc:(//([^/]*))?/?([^?]*)(\?(.*))?", uri)
     if not match:
         print "Invalid irc URI: %s" % uri
         return
@@ -207,7 +208,7 @@
 
     def correct_server(account):
         username = cpurple.PurpleAccountGetUsername(account)
-        return ("@" in username) and (server == (username.split("@"))[1])
+        return ((server == "") or ("@" in username) and (server == (username.split("@"))[1]))
 
     account = findaccount(protocol, matcher=correct_server)