mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
in Later nick validation, use irc.isNick. now instead of forcing strictRfc to true, we are using the config.
This commit is contained in:
parent
e46948400d
commit
261a646451
@ -101,7 +101,7 @@ class Later(callbacks.Plugin):
|
|||||||
self.wildcards.append(nick)
|
self.wildcards.append(nick)
|
||||||
self._flushNotes()
|
self._flushNotes()
|
||||||
|
|
||||||
def _validateNick(self, nick):
|
def _validateNick(self, irc, nick):
|
||||||
"""Validate nick according to the IRC RFC 2812 spec.
|
"""Validate nick according to the IRC RFC 2812 spec.
|
||||||
|
|
||||||
Reference: http://tools.ietf.org/rfcmarkup?doc=2812#section-2.3.1
|
Reference: http://tools.ietf.org/rfcmarkup?doc=2812#section-2.3.1
|
||||||
@ -113,8 +113,8 @@ class Later(callbacks.Plugin):
|
|||||||
If nick incorrigibly invalid, return False, otherwise,
|
If nick incorrigibly invalid, return False, otherwise,
|
||||||
return (possibly trimmed) nick.
|
return (possibly trimmed) nick.
|
||||||
"""
|
"""
|
||||||
if not ircutils.isNick(nick, strictRfc=True):
|
if not irc.isNick(nick):
|
||||||
if not ircutils.isNick(nick[:-1], strictRfc=True):
|
if not irc.isNick(nick[:-1]):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return nick[:-1]
|
return nick[:-1]
|
||||||
@ -131,7 +131,7 @@ class Later(callbacks.Plugin):
|
|||||||
if ircutils.strEqual(nick, irc.nick):
|
if ircutils.strEqual(nick, irc.nick):
|
||||||
irc.error(_('I can\'t send notes to myself.'))
|
irc.error(_('I can\'t send notes to myself.'))
|
||||||
return
|
return
|
||||||
validnick = self._validateNick(nick)
|
validnick = self._validateNick(irc, nick)
|
||||||
if validnick is False:
|
if validnick is False:
|
||||||
irc.error('That is an invalid IRC nick. Please check your input.')
|
irc.error('That is an invalid IRC nick. Please check your input.')
|
||||||
return
|
return
|
||||||
|
@ -44,10 +44,13 @@ class LaterTestCase(PluginTestCase):
|
|||||||
self.assertRegexp('later notes', 'foo')
|
self.assertRegexp('later notes', 'foo')
|
||||||
|
|
||||||
def testNickValidation(self):
|
def testNickValidation(self):
|
||||||
|
origconf = conf.supybot.protocols.irc.strictRfc()
|
||||||
|
conf.supybot.protocols.irc.strictRfc.setValue('True')
|
||||||
self.assertError('later tell 1foo bar')
|
self.assertError('later tell 1foo bar')
|
||||||
self.assertError('later tell foo$moo zoob')
|
self.assertError('later tell foo$moo zoob')
|
||||||
self.assertNotError('later tell foo: baz')
|
self.assertNotError('later tell foo: baz')
|
||||||
self.assertRegexp('later notes', 'foo\.')
|
self.assertRegexp('later notes', 'foo\.')
|
||||||
|
conf.supybot.protocols.irc.strictRfc.setValue(origconf)
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user