From 8db238e869208d29d35cac10f0aa6899d3eb3cb1 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 9 Jun 2021 20:16:31 -0700 Subject: [PATCH] ircs2s_common: only read sender prefixes on lines starting with ":" This fixes incorrect behaviour if the nick of a sender matches that of a S2S command (e.g. "ping") --- protocols/ircs2s_common.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index 4b98252..533926d 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -310,19 +310,18 @@ class IRCS2SProtocol(IRCCommonProtocol): args = self.parse_args(data) sender = args[0] - sender = sender.lstrip(':') + if sender.startswith(':'): + sender = sender[1:] - # If the sender isn't in numeric format, try to convert it automatically. - sender_sid = self._get_SID(sender) - sender_uid = self._get_UID(sender) + # If the sender isn't in numeric format, try to convert it automatically. + sender_sid = self._get_SID(sender) + sender_uid = self._get_UID(sender) - if sender_sid in self.servers: - # Sender is a server (converting from name to SID gave a valid result). - sender = sender_sid - elif sender_uid in self.users: - # Sender is a user (converting from name to UID gave a valid result). - sender = sender_uid - elif not (args[0].startswith(':')): + if sender_sid in self.servers: + sender = sender_sid + elif sender_uid in self.users: + sender = sender_uid + else: # No sender prefix; treat as coming from uplink IRCd. sender = self.uplink args.insert(0, sender)