mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Made sure no information is leaked with last being able to return private messages.
This commit is contained in:
parent
71bba5d28c
commit
457de48be4
@ -41,6 +41,7 @@ import getopt
|
||||
import pprint
|
||||
import smtplib
|
||||
import textwrap
|
||||
from itertools import ifilter
|
||||
|
||||
import conf
|
||||
import debug
|
||||
@ -311,6 +312,11 @@ class MiscCommands(callbacks.Privmsg):
|
||||
except IndexError:
|
||||
irc.error(msg, 'That\'s all, there is no more.')
|
||||
|
||||
def _validLastMsg(self, msg):
|
||||
return msg.prefix and \
|
||||
msg.command == 'PRIVMSG' and \
|
||||
ircutils.isChannel(msg.args[0])
|
||||
|
||||
def last(self, irc, msg, args):
|
||||
"""[--{from,in,to,with,regexp,fancy}] <args>
|
||||
|
||||
@ -346,12 +352,10 @@ class MiscCommands(callbacks.Privmsg):
|
||||
return
|
||||
predicates.append(lambda m: r.search(m.args[1]))
|
||||
first = True
|
||||
for m in reviter(irc.state.history):
|
||||
for m in ifilter(self._validLastMsg, reviter(irc.state.history)):
|
||||
if first:
|
||||
first = False
|
||||
continue
|
||||
if not m.prefix or m.command != 'PRIVMSG':
|
||||
continue
|
||||
for predicate in predicates:
|
||||
if not predicate(m):
|
||||
break
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
from test import *
|
||||
|
||||
class MiscCommandsTestCase(PluginTestCase, PluginDocumentation):
|
||||
class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
plugins = ('MiscCommands', 'Utilities', 'ChannelDB')
|
||||
def testReplyWhenNotCommand(self):
|
||||
conf.replyWhenNotCommand = True
|
||||
@ -95,9 +95,9 @@ class MiscCommandsTestCase(PluginTestCase, PluginDocumentation):
|
||||
def testLast(self):
|
||||
self.feedMsg('foo bar baz')
|
||||
self.assertResponse('last', 'foo bar baz')
|
||||
self.assertResponse('last', 'last')
|
||||
self.assertRegexp('last', 'last')
|
||||
self.assertResponse('last --with foo', 'foo bar baz')
|
||||
self.assertResponse('last --regexp m/\s+/', 'last --with foo')
|
||||
self.assertRegexp('last --regexp m/\s+/', 'last --with foo')
|
||||
self.assertResponse('last --regexp m/bar/', 'foo bar baz')
|
||||
|
||||
def testMore(self):
|
||||
|
Loading…
Reference in New Issue
Block a user