From 4fa8d18621b123cdb6182150c5895d35c04fa5ab Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 23 Jun 2022 19:01:25 +0300 Subject: [PATCH] utf8 encoding checks when reading files in the view --- core/views/expo.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/core/views/expo.py b/core/views/expo.py index 66dffd0..6256aab 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -1,6 +1,9 @@ import os import re import subprocess + +from sys import getfilesystemencoding as sys_getfilesystemencoding + from pathlib import Path from urllib.parse import urljoin, unquote as urlunquote from urllib.request import urlopen @@ -125,7 +128,12 @@ def expowebpage(request, expowebpath, path): # Should not get here if the path has suffix "_edit" print(f' - 404 error in expowebpage() {path}') return render(request, 'pagenotfound.html', {'path': path}, status="404") - + + # print(f' - {sys_getfilesystemencoding()=}') + if (sys_getfilesystemencoding() != "utf-8"): + return HttpResponse(default_head + '

UTF-8 Parsing Failure:
Default file encoding on this Troggle installation is not UTF-8:
failure detected in expowebpage in views.expo.py

Please Please reconfigure Debian/Apache/Django to fix this, i.e. contact Wookey. UTF-8 Parsing Failure:
Default file encoding on this Troggle installation is not UTF-8:
failure detected in expowebpage in views.expo.py Please Please reconfigure Debian/Apache/Django to fix this, i.e. contact Wookey. UTF-8 Parsing Failure:
Default file encoding on this Troggle installation is not UTF-8:
failure detected in expowebpage in views.expo.py Please Please reconfigure Debian/Apache/Django to fix this, i.e. contact Wookey.