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 <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2011-08-02 22:19:47 -04:00
parent b0e595fbd2
commit 0cd4939678
1 changed files with 4 additions and 7 deletions

View File

@ -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]