From caff9caa6c0a32a950608fb309406c9eb175e1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sat, 17 Apr 2021 11:07:30 +0300 Subject: [PATCH 1/1] Composing an URL with an IPv6 host The brackets that were removed must be put back if needed. --- src/gmutil.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gmutil.c b/src/gmutil.c index 34132015..c0eda099 100644 --- a/src/gmutil.c +++ b/src/gmutil.c @@ -290,8 +290,15 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat appendCStr_String(absolute, "://"); /* Authority. */ { const iUrl *selHost = isDef_(rel.host) ? &rel : &orig; + const iBool isIPv6 = iStrStrN(selHost->host.start, ":", size_Range(&selHost->host)) != NULL; iString *decHost = punyDecodeHost_(selHost->host); + if (isIPv6) { + appendCStr_String(absolute, "["); + } append_String(absolute, decHost); + if (isIPv6) { + appendCStr_String(absolute, "]"); + } delete_String(decHost); /* Default Gemini port is removed as redundant; normalization. */ if (!isEmpty_Range(&selHost->port) && (!equalCase_Rangecc(scheme, "gemini") -- 2.34.1