From d7e03f77785f07538c57ac8c23efeb98750c5610 Mon Sep 17 00:00:00 2001 From: Ploum Date: Thu, 19 Sep 2024 15:14:39 +0200 Subject: [PATCH] fix redirecting to standard port in gemini, like gemini.ucant.org --- CHANGELOG | 1 + ansicat.py | 2 +- netcache.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) mode change 100644 => 100755 netcache.py diff --git a/CHANGELOG b/CHANGELOG index 1ee9dfd..d70e2e4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ - "open" now accept integer as parameters to open links (suggested by Matthieu Rakotojaona) - netcache: use client-certificate when going to a url like gemini://username@site.net (by Bert Livens) - offpunk/netcache: added the "cert" command to list and create client certificates (Bert Livens) +- fix cache not being properly accessed when server redirect to same host with standard port (gemini.ucant.org) ## 2.3 - June 29th 2024 - Wayland clipboard support through wl-clipboard (new suggested dependency) diff --git a/ansicat.py b/ansicat.py index 9dd26e6..facbd20 100755 --- a/ansicat.py +++ b/ansicat.py @@ -1361,7 +1361,7 @@ def get_mime(path,url=None): mime = "mailto" elif os.path.isdir(path): mime = "Local Folder" - elif path.endswith(".gmi"): + elif path.endswith(".gmi") or path.endswith(".gemini"): mime = "text/gemini" elif path.endswith("gophermap"): mime = "text/gopher" diff --git a/netcache.py b/netcache.py old mode 100644 new mode 100755 index 2d0743a..6592c49 --- a/netcache.py +++ b/netcache.py @@ -465,7 +465,7 @@ def _validate_cert(address, host, cert,accept_bad_ssl=False,automatic_choice=Non previously encountered a different certificate for this IP address and hostname. """ - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.UTC) if _HAS_CRYPTOGRAPHY: # Using the cryptography module we can get detailed access # to the properties of even self-signed certs, unlike in @@ -882,7 +882,7 @@ def _fetch_gemini(url,timeout=DEFAULT_TIMEOUT,interactive=True,accept_bad_ssl_ce else: body = fbody cache = write_body(url,body,mime) - return cache,newurl + return cache,url def fetch(url,offline=False,download_image_first=True,images_mode="readable",validity=0,**kwargs): -- 2.45.2