This commit is contained in:
Jeremy Fincher 2003-11-26 12:39:37 +00:00
parent 23968baf49
commit d64f5314f8
2 changed files with 9 additions and 2 deletions

View File

@ -145,12 +145,16 @@ class Utilities(callbacks.Privmsg):
try: try:
f = utils.perlReToReplacer(regexp) f = utils.perlReToReplacer(regexp)
substitution = True substitution = True
except ValueError: except ValueError, e:
irc.error(msg, 'Invalid regexp: %s' % e.args[0]) irc.error(msg, 'Invalid regexp: %s' % e.args[0])
return return
if f is None: if f is None:
irc.error(msg, 'Invalid regexp: %s' % e.args[0]) irc.error(msg, 'Invalid regexp: %s' % e.args[0])
return return
if f(''): # It matches the empty string.
s = 'You probably don\'t want to match the empty string.'
irc.error(msg, s)
else:
irc.reply(msg, f(text)) irc.reply(msg, f(text))

View File

@ -73,6 +73,9 @@ class UtilitiesTestCase(PluginTestCase, PluginDocumentation):
self.assertNotRegexp('re m/foo/ bar', 'has no attribute') self.assertNotRegexp('re m/foo/ bar', 'has no attribute')
self.assertResponse('re m/a\S+y/ "the bot angryman is hairy"','angry') self.assertResponse('re m/a\S+y/ "the bot angryman is hairy"','angry')
def testReNotEmptyString(self):
self.assertError('re s//foo/g blah')
def testReNoEscapingUnpackListOfWrongSize(self): def testReNoEscapingUnpackListOfWrongSize(self):
self.assertNotRegexp('re foo bar baz', 'unpack list of wrong size') self.assertNotRegexp('re foo bar baz', 'unpack list of wrong size')