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')