3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-24 11:14:07 +01:00

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")
This commit is contained in:
James Lu 2021-06-09 20:16:31 -07:00
parent da7f9611bc
commit 8db238e869

View File

@ -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)