From b300d8230a57d0430181bf902a684d7b901f3043 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Fri, 19 Dec 2025 20:36:08 +0000 Subject: Trim spaces from CAP responses The spec technically even requires a trailing space when a single capability is listed. This accepts multiple and leading spaces, too. --- http2irc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'http2irc.py') diff --git a/http2irc.py b/http2irc.py index 8037cb7..da47dc2 100644 --- a/http2irc.py +++ b/http2irc.py @@ -632,7 +632,7 @@ class IRCClientProtocol(asyncio.Protocol): # IRCv3 and SASL elif line.command == 'CAP': if line.params[1] == 'ACK': - for cap in line.params[2].split(' '): + for cap in line.params[2].strip(' ').split(' '): self.logger.debug(f'CAP ACK: {cap}') self.caps.add(cap) if cap == 'sasl' and self.sasl: @@ -641,7 +641,7 @@ class IRCClientProtocol(asyncio.Protocol): self.capReqsPending.remove(cap) elif line.params[1] == 'NAK': self.logger.warning(f'Failed to activate CAP(s): {line.params[2]}') - for cap in line.params[2].split(' '): + for cap in line.params[2].strip(' ').split(' '): self.capReqsPending.remove(cap) if len(self.capReqsPending) == 0: self.send(b'CAP END') -- cgit v1.3.1-10-gc9f91