mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Made safeArgument handle colors correctly.
This commit is contained in:
parent
a4b6ee2028
commit
5ec5b997ca
@ -241,7 +241,7 @@ def isValidArgument(s):
|
|||||||
"""Returns if s is strictly a valid argument for an IRC message."""
|
"""Returns if s is strictly a valid argument for an IRC message."""
|
||||||
return '\r' not in s and '\n' not in s and '\x00' not in s
|
return '\r' not in s and '\n' not in s and '\x00' not in s
|
||||||
|
|
||||||
notFunky = string.ascii[32:]+'\x02'
|
notFunky = string.ascii[32:]+'\x02'+'\x03'
|
||||||
def safeArgument(s):
|
def safeArgument(s):
|
||||||
"""If s is unsafe for IRC, returns a safe version."""
|
"""If s is unsafe for IRC, returns a safe version."""
|
||||||
if isValidArgument(s) and s.translate(string.ascii, notFunky) == '':
|
if isValidArgument(s) and s.translate(string.ascii, notFunky) == '':
|
||||||
|
@ -95,8 +95,10 @@ class FunctionsTestCase(unittest.TestCase):
|
|||||||
def testSafeArgument(self):
|
def testSafeArgument(self):
|
||||||
s = 'I have been running for 9 seconds'
|
s = 'I have been running for 9 seconds'
|
||||||
bolds = ircutils.bold(s)
|
bolds = ircutils.bold(s)
|
||||||
|
colors = ircutils.mircColor(s, 'pink', 'orange')
|
||||||
self.assertEqual(s, ircutils.safeArgument(s))
|
self.assertEqual(s, ircutils.safeArgument(s))
|
||||||
self.assertEqual(bolds, ircutils.safeArgument(bolds))
|
self.assertEqual(bolds, ircutils.safeArgument(bolds))
|
||||||
|
self.assertEqual(colors, ircutils.safeArgument(colors))
|
||||||
|
|
||||||
def testIsIP(self):
|
def testIsIP(self):
|
||||||
self.failIf(ircutils.isIP('a.b.c'))
|
self.failIf(ircutils.isIP('a.b.c'))
|
||||||
|
Loading…
Reference in New Issue
Block a user