From 7db1be44fa2adb036fc108251babe0ca4e350b55 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 8 Jul 2022 14:47:43 +0200 Subject: [PATCH] upstream: compare service nick with case-mapping --- upstream.go | 6 +++--- user.go | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/upstream.go b/upstream.go index 1764c40..c2e2e6e 100644 --- a/upstream.go +++ b/upstream.go @@ -494,16 +494,16 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err } } - if msg.Prefix.Name == serviceNick { + if uc.network.equalCasemap(msg.Prefix.Name, serviceNick) { uc.logger.Printf("skipping %v from soju's service: %v", msg.Command, msg) break } - if target == serviceNick { + if uc.network.equalCasemap(target, serviceNick) { uc.logger.Printf("skipping %v to soju's service: %v", msg.Command, msg) break } - if msg.Prefix.Name == uc.serverPrefix.Name || target == "*" || strings.HasPrefix(target, "$") { + if uc.network.equalCasemap(msg.Prefix.Name, uc.serverPrefix.Name) || target == "*" || strings.HasPrefix(target, "$") { // This is a server message uc.produce("", msg, 0) break diff --git a/user.go b/user.go index b50628d..bc7bbd9 100644 --- a/user.go +++ b/user.go @@ -179,6 +179,10 @@ func (net *network) isStopped() bool { } } +func (net *network) equalCasemap(a, b string) bool { + return net.casemap(a) == net.casemap(b) +} + func userIdent(u *database.User) string { // The ident is a string we will send to upstream servers in clear-text. // For privacy reasons, make sure it doesn't expose any meaningful user