~lioploum/offpunk

4e3d3ce62d07dd4180956cdcc16efceca25ebb55 — Ploum 3 months ago d427287
netcache: add support for IPv6 hostname bug #40
2 files changed, 4 insertions(+), 1 deletions(-)

M CHANGELOG
M netcache.py
M CHANGELOG => CHANGELOG +1 -1
@@ 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)

M netcache.py => netcache.py +3 -0
@@ 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))