summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Green <martin.speleo@gmail.com>2022-06-20 21:35:51 +0100
committerMartin Green <martin.speleo@gmail.com>2022-06-20 21:35:51 +0100
commita664e8ce8ccc6ab620d537e68aa8d6d067d6ef9e (patch)
treeef1c86b80bdca70b8204fdf63c4c5e111221044b
parent491fba7d64886ac322ab661d4f58762c7710d0aa (diff)
downloadtroggle-a664e8ce8ccc6ab620d537e68aa8d6d067d6ef9e.tar.gz
troggle-a664e8ce8ccc6ab620d537e68aa8d6d067d6ef9e.tar.bz2
troggle-a664e8ce8ccc6ab620d537e68aa8d6d067d6ef9e.zip
Made it such that opening files for reading and writing when editing to use utf8 encoding
-rw-r--r--core/views/expo.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/views/expo.py b/core/views/expo.py
index 3c60e92..5c0549f 100644
--- a/core/views/expo.py
+++ b/core/views/expo.py
@@ -283,7 +283,7 @@ def editexpopage(request, path):
try:
filepath = Path(settings.EXPOWEB) / path
o = open(os.path.normpath(filepath).encode(sysdefaultencoding), "r")
- html = o.read()
+ html = o.read(encoding="utf8")
autogeneratedmatch = re.search(r"\<\!--\s*(.*?(Do not edit|It is auto-generated).*?)\s*--\>", html, re.DOTALL + re.IGNORECASE)
if autogeneratedmatch:
return HttpResponse(autogeneratedmatch.group(1))
@@ -331,7 +331,7 @@ def editexpopage(request, path):
# GIT see also core/models/cave.py writetrogglefile()
# GIT see also core/views/uploads.py dwgupload()
try:
- with open(os.path.normpath(filepath).encode(sysdefaultencoding), "w") as f:
+ with open(os.path.normpath(filepath).encode(sysdefaultencoding), "w", encoding="utf8") as f:
print(f'WRITING{cwd}---{filename} ')
# as the wsgi process www-data, we have group write-access but are not owner, so cannot chmod.
# os.chmod(filepath, 0o664) # set file permissions to rw-rw-r--