summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-04-28 00:30:43 +0300
committerPhilip Sargent <philip.sargent@klebos.com>2022-04-28 00:30:43 +0300
commitf0634ff164ba06382d9c97458a3d96e407f4dbee (patch)
tree847ff26c855dd6de0bf2a68b4e3c0e640cab1ee3 /core
parent322d454d415b4dcb56e1563002fd9a26f08be480 (diff)
downloadtroggle-f0634ff164ba06382d9c97458a3d96e407f4dbee.tar.gz
troggle-f0634ff164ba06382d9c97458a3d96e407f4dbee.tar.bz2
troggle-f0634ff164ba06382d9c97458a3d96e407f4dbee.zip
specify default encoding explicitly
Diffstat (limited to 'core')
-rw-r--r--core/views/expo.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/views/expo.py b/core/views/expo.py
index 1fd01e5..441d4bc 100644
--- a/core/views/expo.py
+++ b/core/views/expo.py
@@ -126,13 +126,16 @@ def expowebpage(request, expowebpath, path):
return render(request, 'pagenotfound.html', {'path': path}, status="404")
try:
- with open(os.path.normpath(expowebpath / path), "r") as o:
+ with open(os.path.normpath(expowebpath / path), "r", encoding='utf-8') as o:
html = o.read()
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:
html = str(o.read()).replace("<h1>","<h1>BAD NON-UTF-8 characters here - ")
html = html.replace("\\n","\n")
+ html = html.replace("\\r","")
html = html.replace("\\t","\t")
html = html.replace("\\'","\'")
except: