geminispace.info

gemini search engine
git clone https://git.clttr.info/geminispace.info.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit cde47da62cb626be45196e66f8f5b8125a4b4827
parent e3f879df8442e16f541954359009f369b26717c0
Author: Natalie Pendragon <natpen@natpen.net>
Date:   Fri, 22 May 2020 07:20:20 -0400

Improve handling of unquoting URLs

Just do it once at the beginning of GeminiResource creation.

Diffstat:
Mgus/lib/gemini.py | 5+----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gus/lib/gemini.py b/gus/lib/gemini.py @@ -50,6 +50,7 @@ def urlsplit_featureful(url, fully_qualified_parent_url=None, parent_hostname=No class GeminiResource(): def __init__(self, url, fully_qualified_parent_url=None, parent_hostname=None): + url = unquote(url) self.raw_url = url self.urlsplit, self.is_relative = urlsplit_featureful( url, @@ -104,8 +105,6 @@ class GeminiResource(): return None if self._fully_qualified_massaged_url is None: fully_qualified_massaged_url = self.fully_qualified_url - if "%" in fully_qualified_massaged_url: - fully_qualified_massaged_url = unquote(fully_qualified_massaged_url) if self.urlsplit.port == 1965: fully_qualified_massaged_url = url_normalized.replace(self.urlsplit.hostname.lower() + ":1965", self.urlsplit.hostname.lower(), 1) self._fully_qualified_massaged_url = fully_qualified_massaged_url @@ -127,8 +126,6 @@ class GeminiResource(): def _get_normalized_url_and_host(self): url_normalized = self.fully_qualified_url.lower().rstrip("/") - if "%" in url_normalized: - url_normalized = unquote(url_normalized) if self.urlsplit.port == 1965: url_normalized = url_normalized.replace(self.urlsplit.hostname.lower() + ":1965", self.urlsplit.hostname.lower(), 1) host_normalized = self.urlsplit.hostname.lower()