From 1932ed4d02003501530daec958f6c3fee2aa4fa9 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 10 Dec 2004 08:48:24 +0000 Subject: [PATCH] Slight bugfix in isCtcp. --- src/ircmsgs.py | 3 ++- test/test_ircmsgs.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ircmsgs.py b/src/ircmsgs.py index f0d49203b..2f6ea639e 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -213,7 +213,8 @@ def isCtcp(msg): """Returns whether or not msg is a CTCP message.""" return msg.command in ('PRIVMSG', 'NOTICE') and \ msg.args[1].startswith('\x01') and \ - msg.args[1].endswith('\x01') + msg.args[1].endswith('\x01') and \ + len(msg.args[1]) >= 2 def isAction(msg): """A predicate returning true if the PRIVMSG in question is an ACTION""" diff --git a/test/test_ircmsgs.py b/test/test_ircmsgs.py index 5a05bcd4f..ef6012a31 100644 --- a/test/test_ircmsgs.py +++ b/test/test_ircmsgs.py @@ -147,6 +147,7 @@ class FunctionsTestCase(SupyTestCase): def testIsCtcp(self): self.failUnless(ircmsgs.isCtcp(ircmsgs.privmsg('foo', '\x01VERSION\x01'))) + self.failIf(ircmsgs.isCtcp(ircmsgs.privmsg('foo', '\x01'))) def testIsActionFalseWhenNoSpaces(self): msg = ircmsgs.IrcMsg('PRIVMSG #foo :\x01ACTIONfoobar\x01')