From 2d6f22ae76b5979d33f94f597e2f8b70d3f150a3 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 21 Aug 2003 12:46:52 +0000 Subject: [PATCH] Fixed a bug in the regexp; removed a latent security bug that was just waiting for that regexp bug to be fixed. --- plugins/FixRelayBot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/FixRelayBot.py b/plugins/FixRelayBot.py index 1d4980cd7..06c4f7245 100644 --- a/plugins/FixRelayBot.py +++ b/plugins/FixRelayBot.py @@ -37,12 +37,13 @@ to access the bot. from baseplugin import * import re +import random import irclib import ircmsgs class FixRelayBot(irclib.IrcCallback): - _re = re.compile('<([^@]+)@([^>])+>\s+(.*)') + _re = re.compile(r'<([^@]+)@[^>]+>\s+(.*)') def inFilter(self, irc, msg): if msg.command == 'PRIVMSG': #debug.printf('Message command was PRIVMSG') @@ -51,7 +52,8 @@ class FixRelayBot(irclib.IrcCallback): #debug.printf('Regexp matched: %r, %r, %r' % m.groups()) nick = m.group(1) network = m.group(2) - newprefix = '%s!%s@%s' % (nick, nick, network) + host = random.random()*100 + newprefix = ircutils.joinHostmask(nick, nick, host) msg = ircmsgs.IrcMsg(command='PRIVMSG', prefix=newprefix, args=(msg.args[0], m.group(3))) return msg