From 0cd4939678e5839c85b57460c7c4b000c8fc1751 Mon Sep 17 00:00:00 2001 From: James Vega Date: Tue, 2 Aug 2011 22:19:47 -0400 Subject: [PATCH] Seen: Anchor nick regexp to ensure valid match. When searching for 'st*ke', 'stryker' would incorrectly match, 'stryke' would be added to the nick set and the subsequent lookup would cause a KeyError. This is fixed both by anchoring the regexp ('^st.*ke$' instead of 'st.*ke') and adding searchNick to the nick set instead of the string that matched the pattern. Closes: Sf#3377381 Signed-off-by: James Vega --- plugins/Seen/plugin.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index d5bc6275e..c4255b172 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2004, Jeremiah Fincher -# Copyright (c) 2010, James Vega +# Copyright (c) 2010-2011, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -66,7 +66,7 @@ class SeenDB(plugins.ChannelUserDB): def seenWildcard(self, channel, nick): nicks = ircutils.IrcSet() - nickRe = re.compile('.*'.join(nick.split('*')), re.I) + nickRe = re.compile('^%s$' % '.*'.join(nick.split('*')), re.I) for (searchChan, searchNick) in self.keys(): #print 'chan: %s ... nick: %s' % (searchChan, searchNick) if isinstance(searchNick, int): @@ -75,11 +75,8 @@ class SeenDB(plugins.ChannelUserDB): # are keyed by nick-string continue if ircutils.strEqual(searchChan, channel): - try: - s = nickRe.match(searchNick).group() - except AttributeError: - continue - nicks.add(s) + if nickRe.search(searchNick) is not None: + nicks.add(searchNick) L = [[nick, self.seen(channel, nick)] for nick in nicks] def negativeTime(x): return -x[1][0]