diff --git a/CHANGELOG b/CHANGELOG index cd88318..daa8fe9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ # Offpunk History ## 2.3 - Unreleased -- offpunk: fix IPv6 as an URL (bug #40) +- offpunk/netcache: fix IPv6 as an URL (bug #40) ## 2.2 - February 13th 2023 - cache folder is now configurable through $OFFPUNK_CACHE_PATH environment variable (by prx) diff --git a/netcache.py b/netcache.py index 7465f85..2e91a8a 100755 --- a/netcache.py +++ b/netcache.py @@ -656,6 +656,9 @@ def _fetch_gemini(url,timeout=DEFAULT_TIMEOUT,interactive=True,accept_bad_ssl_ce # Send request and wrap response in a file descriptor url = urllib.parse.urlparse(url) new_netloc = host + #Handle IPV6 hostname + if ":" in new_netloc: + new_netloc = "[" + new_netloc + "]" if port != standard_ports["gemini"]: new_netloc += ":" + str(port) url = urllib.parse.urlunparse(url._replace(netloc=new_netloc))