This commit is contained in:
Martin Green 2022-06-19 01:37:51 +01:00
parent c9d7931ccb
commit 3465e9bd16

View File

@ -131,11 +131,11 @@ def expowebpage(request, expowebpath, path):
try:
with open(os.path.normpath(expowebpath / path).encode(sysdefaultencoding), "r", encoding='utf-8') as o:
html = o.read()
except Cave.DoesNotExist:
except:
# exception raised on debian with python 3.9.2 but not on WSL Ubuntu with python 3.9.5
# because debian was assuming default text encoding was 'ascii'. Now specified explicitly so should be OK
try:
with open(os.path.normpath(expowebpath / path), "rb") as o:
with open(os.path.normpath(expowebpath / path).encode(sysdefaultencoding), "rb") as o:
html = str(o.read()).replace("<h1>","<h1>BAD NON-UTF-8 characters here - ")
html = html.replace("\\n","\n")
html = html.replace("\\r","")