mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Trying something out for fixing the Jawoota unicode bug.
This commit is contained in:
parent
ac74ef9819
commit
d2d5f880ed
@ -320,14 +320,14 @@ def unColor(s):
|
|||||||
return _unColorRe.sub('', s)
|
return _unColorRe.sub('', s)
|
||||||
|
|
||||||
def isValidArgument(s):
|
def isValidArgument(s):
|
||||||
"""Returns if s is strictly a valid argument for an IRC message."""
|
"""Returns whether 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\x03\x0F\x16\x1F'
|
|
||||||
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."""
|
||||||
assert not isinstance(s, unicode),'Unicode strings are not allowed in IRC.'
|
if isinstance(s, unicode):
|
||||||
if isValidArgument(s) and s.translate(string.ascii, notFunky) == '':
|
s = s.encode('utf-8')
|
||||||
|
if isValidArgument(s):
|
||||||
return s
|
return s
|
||||||
else:
|
else:
|
||||||
return repr(s)
|
return repr(s)
|
||||||
|
Loading…
Reference in New Issue
Block a user