Fixed bug in ircutils.isNick, which allowed nicks to start with dashes.

This commit is contained in:
Jeremy Fincher 2005-08-02 02:47:42 +00:00
parent 14acfcafe4
commit cede4a4a97
2 changed files with 4 additions and 3 deletions

View File

@ -114,10 +114,9 @@ def strEqual(nick1, nick2):
nickEqual = strEqual nickEqual = strEqual
_nickchars = r'_[]\`^{}|-' _nickchars = r'[]\`_^{|}'
nickRe = re.compile(r'^[A-Za-z%s][0-9A-Za-z%s]*$' nickRe = re.compile(r'^[A-Za-z%s][-0-9A-Za-z%s]*$'
% (re.escape(_nickchars), re.escape(_nickchars))) % (re.escape(_nickchars), re.escape(_nickchars)))
def isNick(s, strictRfc=True, nicklen=None): def isNick(s, strictRfc=True, nicklen=None):
"""s => bool """s => bool
Returns True if s is a valid IRC nick.""" Returns True if s is a valid IRC nick."""

View File

@ -187,6 +187,8 @@ class FunctionsTestCase(SupyTestCase):
self.failIf(ircutils.isNick('')) self.failIf(ircutils.isNick(''))
self.failIf(ircutils.isNick('8foo')) self.failIf(ircutils.isNick('8foo'))
self.failIf(ircutils.isNick('10')) self.failIf(ircutils.isNick('10'))
self.failIf(ircutils.isNick('-'))
self.failIf(ircutils.isNick('-foo'))
conf.supybot.protocols.irc.strictRfc.setValue(False) conf.supybot.protocols.irc.strictRfc.setValue(False)
self.failUnless(ircutils.isNick('services@something.undernet.net')) self.failUnless(ircutils.isNick('services@something.undernet.net'))
finally: finally: