diff options
Diffstat (limited to 'core/views/expo.py')
-rw-r--r-- | core/views/expo.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/views/expo.py b/core/views/expo.py index 885eafd..66dffd0 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -121,19 +121,19 @@ def expofilesdir(request, dirpath, filepath): def expowebpage(request, expowebpath, path): '''Adds menus and serves an HTML page ''' - if not os.path.isfile(os.path.normpath(expowebpath / path).encode(sysdefaultencoding)): + if not os.path.isfile(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") try: - with open(os.path.normpath(expowebpath / path).encode(sysdefaultencoding), "r", encoding='utf-8') as o: + with open(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).encode(sysdefaultencoding), "rb") as o: + with open(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","") @@ -156,7 +156,7 @@ def expowebpage(request, expowebpath, path): if m: editable = False else: - editable = os.access(os.path.normpath(expowebpath / path).encode(sysdefaultencoding), os.W_OK) # are file permissions writeable? + editable = os.access(expowebpath / path, os.W_OK) # are file permissions writeable? has_menu = False menumatch = re.match(r'(.*)<div id="menu">', body, re.DOTALL + re.IGNORECASE) |