fixes hang/crash when meeting ; itemtype in gopher

This commit is contained in:
Ploum 2023-11-01 23:45:47 +01:00
parent 29c447cd8e
commit bf17b21b30
3 changed files with 4 additions and 3 deletions

View File

@ -17,6 +17,7 @@ Changes since beta1
- fixes a bug in HTML renderer where some hX element were not closed properly
- fixes input in Gemini while online
- fixes a crash with invalid URL
- fixes hang/crash when meeting the ";" itemtype in gopher
- attempt at hiding XMLparsedAsHTMLWarning from BS4 library
- chafa now used by default everywhere if version > 1.10
- ignoring encoding error in ansicat

View File

@ -1247,7 +1247,7 @@ def get_mime(path,url=None):
mime = "text/gopher"
elif itemtype == "h":
mime = "text/html"
elif itemtype in ("9","g","I","s"):
elif itemtype in ("9","g","I","s",";"):
mime = "binary"
else:
mime = "text/gopher"

View File

@ -371,7 +371,7 @@ def _fetch_gopher(url,timeout=DEFAULT_TIMEOUT,**kwargs):
response = s.makefile("rb").read()
# Transcode response into UTF-8
#if itemtype in ("0","1","h"):
if not itemtype in ("9","g","I","s"):
if not itemtype in ("9","g","I","s",";"):
# Try most common encodings
for encoding in ("UTF-8", "ISO-8859-1"):
try:
@ -392,7 +392,7 @@ def _fetch_gopher(url,timeout=DEFAULT_TIMEOUT,**kwargs):
mime = "text/gopher"
elif itemtype == "h":
mime = "text/html"
elif itemtype in ("9","g","I","s"):
elif itemtype in ("9","g","I","s",";"):
mime = None
else:
# by default, we should consider Gopher