ircmsgs: use classic comparisons instead of str.translate to ensure channel key validity.

This commit is contained in:
Valentin Lorentz 2012-08-04 13:31:26 +02:00
parent e23fa611d6
commit 17eb6c497f

View File

@ -602,15 +602,8 @@ def join(channel, key=None, prefix='', msg=None):
return IrcMsg(prefix=prefix, command='JOIN', args=(channel,), msg=msg) return IrcMsg(prefix=prefix, command='JOIN', args=(channel,), msg=msg)
else: else:
if conf.supybot.protocols.irc.strictRfc(): if conf.supybot.protocols.irc.strictRfc():
assert key.translate(utils.str.chars, chars = utils.str.chars[128:] + '\x00\r\n\f\t\v '
utils.str.chars[128:]) == key and \ assert not any([x in chars for x in key])
'\x00' not in key and \
'\r' not in key and \
'\n' not in key and \
'\f' not in key and \
'\t' not in key and \
'\v' not in key and \
' ' not in key
return IrcMsg(prefix=prefix, command='JOIN', return IrcMsg(prefix=prefix, command='JOIN',
args=(channel, key), msg=msg) args=(channel, key), msg=msg)
@ -628,17 +621,10 @@ def joins(channels, keys=None, prefix='', msg=None):
command='JOIN', command='JOIN',
args=(','.join(channels),), msg=msg) args=(','.join(channels),), msg=msg)
else: else:
for key in keys: if conf.supybot.protocols.irc.strictRfc():
if conf.supybot.protocols.irc.strictRfc(): chars = utils.str.chars[128:] + '\x00\r\n\f\t\v '
assert key.translate(utils.str.chars, for key in keys:
utils.str.chars[128:])==key and \ assert not any([x in chars for x in key])
'\x00' not in key and \
'\r' not in key and \
'\n' not in key and \
'\f' not in key and \
'\t' not in key and \
'\v' not in key and \
' ' not in key
return IrcMsg(prefix=prefix, return IrcMsg(prefix=prefix,
command='JOIN', command='JOIN',
args=(','.join(channels), ','.join(keys)), msg=msg) args=(','.join(channels), ','.join(keys)), msg=msg)