- don't crash if unicode parsing fails, don't require nickname for admin masks

Mon, 16 Jun 2014 00:14:56 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 16 Jun 2014 00:14:56 +0300
changeset 16
6672cecf3ed1
parent 15
e7999383db5a
child 17
f604687dd35b

- don't crash if unicode parsing fails, don't require nickname for admin masks

cobalt.py file | annotate | diff | comparison | revisions
--- a/cobalt.py	Sun Jun 15 21:19:43 2014 +0300
+++ b/cobalt.py	Mon Jun 16 00:14:56 2014 +0300
@@ -166,7 +166,7 @@
 sys.excepthook = handle_exception
 
 def check_admin (sender, ident, host, command):
-	if not "%s!%s@%s" % (sender, ident, host) in g_admins:
+	if not "%s@%s" % (ident, host) in g_admins:
 		raise logical_exception (".%s requires admin access" % command)
 
 class logical_exception (Exception):
@@ -246,7 +246,11 @@
 	def handle_read (self):
 		lines = self.recv (4096).splitlines()
 		for utfline in lines:
-			line = utfline.decode("utf-8").encode("ascii","ignore")
+			try:
+				line = utfline.decode("utf-8").encode("ascii","ignore")
+			except UnicodeDecodeError:
+				continue
+
 			if self.verbose:
 				print "[%s] -> %s" % (self.name, line)
 

mercurial