From bf20721be5c30f5efc9107d50e8dec3825b9b42c Mon Sep 17 00:00:00 2001 From: Lionel Dricot Date: Sun, 13 Feb 2022 23:18:42 +0100 Subject: [PATCH] fix crash with some mailto links --- offpunk.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/offpunk.py b/offpunk.py index a2cd786..44291fe 100755 --- a/offpunk.py +++ b/offpunk.py @@ -196,6 +196,8 @@ def fix_ipv6_url(url): return if not url.count(":") > 2: # Best way to detect them? return url + if url.startswith("mailto"): + return url # If there's a pair of []s in there, it's probably fine as is. if "[" in url and "]" in url: return url @@ -1103,7 +1105,10 @@ class GeminiItem(): mime2,encoding = mimetypes.guess_type(path,strict=False) #If we hesitate between html and xml, takes the xml one #because the FeedRendered fallback to HtmlRenderer - if mime != mime2 and "html" in mime and "xml" in mime2: + if mime2 and mime != mime2 and "html" in mime and "xml" in mime2: + mime = "text/xml" + #Some xml/html document are considered as octet-stream + if mime == "application/octet-stream": mime = "text/xml" else: mime,encoding = mimetypes.guess_type(path,strict=False)