From d64f5314f8ac54b40fee3ded2408be7369f21d54 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 26 Nov 2003 12:39:37 +0000 Subject: [PATCH] Fix for bug #849619. --- plugins/Utilities.py | 8 ++++++-- test/test_Utilities.py | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/Utilities.py b/plugins/Utilities.py index c02065abc..019c31a73 100644 --- a/plugins/Utilities.py +++ b/plugins/Utilities.py @@ -145,13 +145,17 @@ class Utilities(callbacks.Privmsg): try: f = utils.perlReToReplacer(regexp) substitution = True - except ValueError: + except ValueError, e: irc.error(msg, 'Invalid regexp: %s' % e.args[0]) return if f is None: irc.error(msg, 'Invalid regexp: %s' % e.args[0]) return - irc.reply(msg, f(text)) + 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)) Class = Utilities diff --git a/test/test_Utilities.py b/test/test_Utilities.py index 1cd9c6bc9..f2c67b9ef 100644 --- a/test/test_Utilities.py +++ b/test/test_Utilities.py @@ -73,6 +73,9 @@ class UtilitiesTestCase(PluginTestCase, PluginDocumentation): self.assertNotRegexp('re m/foo/ bar', 'has no attribute') 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): self.assertNotRegexp('re foo bar baz', 'unpack list of wrong size')