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>
(cherry picked from commit 0cd4939678)

Signed-off-by: Daniel Folkinshteyn <nanotube@users.sourceforge.net>
This commit is contained in:
James Vega 2011-08-02 22:19:47 -04:00 committed by Daniel Folkinshteyn
parent 59936f52f3
commit a8736d9a64

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]