diff options
| author | 2021-12-08 05:23:49 +0000 | |
|---|---|---|
| committer | 2021-12-08 05:23:49 +0000 | |
| commit | 1e69a42eae578730d73b670129762e45f41c2be4 (patch) | |
| tree | 9761093ff6f9c95de6793acc092174462666da05 | |
| parent | Add support for INVITE after getting KICKed from a channel (diff) | |
| signature | ||
Fix usermask length calculation
Didn't account for the ! and @ symbols, so in certain cases, two bytes at the ends of lines vanished.
| -rw-r--r-- | http2irc.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/http2irc.py b/http2irc.py index 85a7d1c..4498a4c 100644 --- a/http2irc.py +++ b/http2irc.py @@ -516,7 +516,7 @@ class IRCClientProtocol(asyncio.Protocol): def _self_usermask_length(self): if not self.server.nickname or not self.server.username or not self.server.hostname: return 100 - return len(self.server.nickname) + len(self.server.username) + len(self.server.hostname) + return len(self.server.nickname) + 1 + len(self.server.username) + 1 + len(self.server.hostname) # nickname!username@hostname async def send_messages(self): while self.connected: @@ -527,7 +527,7 @@ class IRCClientProtocol(asyncio.Protocol): break channelB = channel.encode('utf-8') messageB = message.encode('utf-8') - usermaskPrefixLength = 1 + self._self_usermask_length() + 1 + usermaskPrefixLength = 1 + self._self_usermask_length() + 1 # :usermask<SP> if usermaskPrefixLength + len(b'PRIVMSG ' + channelB + b' :' + messageB) > 510: # Message too long, need to split or truncate. First try to split on spaces, then on codepoints. Ideally, would use graphemes between, but that's too complicated. self.logger.debug(f'Message too long, overlongmode = {overlongmode}') |
