~emersion/soju-dev

xirc: Fix sending hostnames starting with ':' in WHO replies v1 APPLIED

delthas: 1
 xirc: Fix sending hostnames starting with ':' in WHO replies

 1 files changed, 5 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/38342/mbox | git am -3
Learn more about email & git

[PATCH] xirc: Fix sending hostnames starting with ':' in WHO replies Export this patch

Some IPv6 hostnames can start with a colon (eg '::1'). This breaks
the IRC line format.

To work around this issue, prefix the hostname with a '0'. This
changes the representation of the IP but not its value.

See: https://todo.sr.ht/~taiite/senpai/109
---
 xirc/whox.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xirc/whox.go b/xirc/whox.go
index 2e11813..ee5978c 100644
--- a/xirc/whox.go
+++ b/xirc/whox.go
@@ -80,6 +80,11 @@ func (info *WHOXInfo) set(k byte, v string) {
}

func GenerateWHOXReply(prefix *irc.Prefix, nick, fields string, info *WHOXInfo) *irc.Message {
	if strings.HasPrefix(info.Hostname, ":") {
		// The hostname cannot start with a colon as this would get parsed as a trailing parameter.
		// IPv6 addresses such as "::1" are prefixed with a zero to ensure this.
		info.Hostname = "0" + info.Hostname
	}
	if fields == "" {
		return &irc.Message{
			Prefix:  prefix,

base-commit: 959baa964f45b40fad239e21a246e3b963f9ca57
-- 
2.38.0
Edited to not mutate the field. Pushed, thanks!