From b9ab83947001ba1f42b67bdac7bb4b352e77082d Mon Sep 17 00:00:00 2001 From: James Vega Date: Thu, 15 Apr 2004 21:20:52 +0000 Subject: [PATCH] BadWords will now filter words that have been formatted --- ChangeLog | 2 ++ plugins/BadWords.py | 2 ++ test/test_BadWords.py | 1 + 3 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index ee0789b8e..b333525b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * Fixed bug #863601, plugin BadWords fails on color codes. + * Added ircutils.strip{Bold,Reverse,Underline,Formatting}, which will remove the specified formatting or all forms of formatting in the case of stripFormatting. diff --git a/plugins/BadWords.py b/plugins/BadWords.py index db07e94ec..9f81fff5e 100644 --- a/plugins/BadWords.py +++ b/plugins/BadWords.py @@ -47,6 +47,7 @@ import conf import utils import ircdb import ircmsgs +import ircutils import privmsgs import registry import callbacks @@ -122,6 +123,7 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg): self.makeRegexp(self.words()) self.lastModified = time.time() s = msg.args[1] + s = ircutils.stripFormatting(s) s = self.regexp.sub(self.sub, s) return ircmsgs.privmsg(msg.args[0], s) else: diff --git a/test/test_BadWords.py b/test/test_BadWords.py index 54014db78..ce9593eff 100644 --- a/test/test_BadWords.py +++ b/test/test_BadWords.py @@ -41,6 +41,7 @@ class BadWordsTestCase(PluginTestCase, PluginDocumentation): def _test(self): for word in self.badwords: self.assertRegexp('echo %s' % word, '(?!%s)' % word) + self.assertRegexp('echo [colorize %s]' % word, '(?!%s)' % word) self.assertRegexp('echo foo%sbar' % word, '(?!%s)' % word) self.assertRegexp('echo [strjoin "" %s]' % ' '.join(word), '(?!%s)' % word)