From 438a0785fb47fc1ba9fe9421ed47cc9defb15922 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 9 Oct 2012 17:39:50 -0400 Subject: Fix IndexError due to unintentionally moving call out of try block --- logbot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'logbot.py') diff --git a/logbot.py b/logbot.py index 80047c7..b7cc694 100755 --- a/logbot.py +++ b/logbot.py @@ -246,8 +246,9 @@ class Logbot(SingleServerIRCBot): try: msg = msg.replace("%channel%", event.target()) except: pass msg = msg.replace("%color%", self.color(nm_to_n(event.source()))) - user_message = cgi.escape(event.arguments()[0]) - try: msg = msg.replace("%message%", html_color(user_message)) + try: + user_message = cgi.escape(event.arguments()[0]) + msg = msg.replace("%message%", html_color(user_message)) except: pass return msg -- cgit v1.2.3-70-g09d2 From 1f4a5bd42cefa816d8ec9c1b7c60b6255150da0e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 9 Oct 2012 17:41:17 -0400 Subject: Fix possible KeyError if code is not a color code --- logbot.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'logbot.py') diff --git a/logbot.py b/logbot.py index b7cc694..3bc5dd1 100755 --- a/logbot.py +++ b/logbot.py @@ -198,6 +198,8 @@ def replace_color(code, text): '36': '00aaaa', '37': 'F5F1DE', } + if code not in colors: + return text return '%(text)s' % dict( color = colors[code], text = text, -- cgit v1.2.3-70-g09d2