From e54e17a0eadb0a2e22b95d4957914bc7b1d274c1 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 9 Jul 2015 17:25:10 -0700 Subject: [PATCH] Irc.send: safeguard against newlines in input! --- main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.py b/main.py index da4aa3a..cc6475b 100755 --- a/main.py +++ b/main.py @@ -75,6 +75,9 @@ class Irc(): sys.exit(1) 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" log.debug("-> %s", data.decode("utf-8").strip("\n")) self.socket.send(data)