src/ircmsgs.py: Assert string parameters are actually strings.

This prevents a plugin from sending another object and messing with outFilter methods of other plugins.
This commit is contained in:
Valentin Lorentz 2012-10-06 21:12:40 +00:00
parent 40801513ac
commit 364a3e50e8

View File

@ -532,6 +532,7 @@ def kick(channel, nick, s='', prefix='', msg=None):
assert isNick(nick), repr(nick)
if msg and not prefix:
prefix = msg.prefix
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='KICK',
args=(channel, nick, s), msg=msg)
@ -547,6 +548,7 @@ def kicks(channel, nicks, s='', prefix='', msg=None):
assert all(isNick, nicks), nicks
if msg and not prefix:
prefix = msg.prefix
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='KICK',
args=(channel, ','.join(nicks), s), msg=msg)
@ -559,6 +561,7 @@ def privmsg(recipient, s, prefix='', msg=None):
if conf.supybot.protocols.irc.strictRfc():
assert (isChannel(recipient) or isNick(recipient)), repr(recipient)
assert s, 's must not be empty.'
assert isinstance(s, str)
if msg and not prefix:
prefix = msg.prefix
return IrcMsg(prefix=prefix, command='PRIVMSG',
@ -588,6 +591,7 @@ def notice(recipient, s, prefix='', msg=None):
if conf.supybot.protocols.irc.strictRfc():
assert (isChannel(recipient) or isNick(recipient)), repr(recipient)
assert s, 'msg must not be empty.'
assert isinstance(s, str)
if msg and not prefix:
prefix = msg.prefix
return IrcMsg(prefix=prefix, command='NOTICE', args=(recipient, s), msg=msg)
@ -635,6 +639,7 @@ def part(channel, s='', prefix='', msg=None):
assert isChannel(channel), repr(channel)
if msg and not prefix:
prefix = msg.prefix
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='PART',
args=(channel, s), msg=msg)
@ -648,6 +653,7 @@ def parts(channels, s='', prefix='', msg=None):
assert all(isChannel, channels), channels
if msg and not prefix:
prefix = msg.prefix
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='PART',
args=(','.join(channels), s), msg=msg)
@ -674,6 +680,7 @@ def topic(channel, topic=None, prefix='', msg=None):
return IrcMsg(prefix=prefix, command='TOPIC',
args=(channel,), msg=msg)
else:
assert isinstance(topic, str)
return IrcMsg(prefix=prefix, command='TOPIC',
args=(channel, topic), msg=msg)