3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-28 05:29:25 +01:00

Irc.send: safeguard against newlines in input!

This commit is contained in:
James Lu 2015-07-09 17:25:10 -07:00
parent 070bba77cb
commit e54e17a0ea

View File

@ -75,6 +75,9 @@ class Irc():
sys.exit(1) sys.exit(1)
def send(self, data): def send(self, data):
# Safeguard against newlines in input!! Otherwise, each line gets
# treated as a separate command, which is particularly nasty.
data = data.replace('\n', ' ')
data = data.encode("utf-8") + b"\n" data = data.encode("utf-8") + b"\n"
log.debug("-> %s", data.decode("utf-8").strip("\n")) log.debug("-> %s", data.decode("utf-8").strip("\n"))
self.socket.send(data) self.socket.send(data)