specify encoding when reading text files

master
Aevann1 2022-06-18 00:19:18 +02:00
parent 28fa03669d
commit 80852cc395
3 changed files with 5 additions and 5 deletions

View File

@ -90,7 +90,7 @@ def before_request():
ua = g.agent.lower()
with open('site_settings.json', 'r') as f:
with open('site_settings.json', 'r', encoding='utf_8') as f:
app.config['SETTINGS'] = json.load(f)
if request.host != app.config["SERVER_NAME"]: return {"error":"Unauthorized host provided."}, 401

View File

@ -494,10 +494,10 @@ def admin_git_head():
# Also, a malicious branch name would mean someone already owned the server
# or repo, so I think this isn't a weak link.
try:
with open('.git/HEAD') as head_f:
with open('.git/HEAD', encoding='utf_8') as head_f:
head_txt = head_f.read()
head_path = re.match('ref: (refs/.+)', head_txt).group(1)
with open('.git/' + head_path) as ref_f:
with open('.git/' + head_path, encoding='utf_8') as ref_f:
gitref = ref_f.read()[0:short_len]
except:
return '<unable to read>'
@ -508,7 +508,7 @@ def admin_git_head():
def change_settings(v, setting):
site_settings = app.config['SETTINGS']
site_settings[setting] = not site_settings[setting]
with open("site_settings.json", "w") as f:
with open("site_settings.json", "w", encoding='utf_8') as f:
json.dump(site_settings, f)
if site_settings[setting]: word = 'enable'

View File

@ -372,7 +372,7 @@ def settings_security(v):
@app.get("/.well-known/assetlinks.json")
def googleplayapp():
with open("files/assets/assetlinks.json", "r") as f:
with open("files/assets/assetlinks.json", "r", encoding='utf_8') as f:
return Response(f.read(), mimetype='application/json')