From 739c87ef50817c1672743f921dc6b71fd1d490f4 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 8 Apr 2019 22:33:55 -0700 Subject: [PATCH] clientbot: only split /names replies by spaces This fixes issues with colored hostnames because \x1f is treated as a whitespace char by str.split(). Closes #641. (cherry picked from commit 905679963331764db17f0bda2dfd7b299d8d2a20) --- protocols/clientbot.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index 04dbbe9..bfc3354 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -681,14 +681,19 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): prefix_to_mode = {v:k for k, v in self.prefixmodes.items()} prefixes = ''.join(self.prefixmodes.values()) - for name in args[-1].split(): + # N.B. only split on spaces because of color in hosts nonsense... + # str.split() by default treats \x1f as whitespace + for name in args[-1].split(' '): nick = name.lstrip(prefixes) # Handle userhost-in-names where available. + ident = host = None if 'userhost-in-names' in self.ircv3_caps: - nick, ident, host = utils.split_hostmask(nick) - else: - ident = host = None + try: + nick, ident, host = utils.split_hostmask(nick) + except ValueError: + log.exception('(%s) Failed to split hostmask %r from /names reply on %s', self.name, nick, channel) + # If error, leave nick unsplit # Get the PUID for the given nick. If one doesn't exist, spawn # a new virtual user.