Reading files as UTF-8, fixes #80

This commit is contained in:
Daniel Perna 2018-08-08 01:00:52 +02:00
parent ed1d6f0d57
commit 6979de0931
2 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,7 @@
Version 0.3.2 (2018-)
- Allow `PASSWORD` to be numeric (Issue #108) @danielperna84
- Sanity check for `ALLOWED_NETWORKS`, `BANNED_IPS` and `IGNORE_PATTERN` (Issue #109) @danielperna84
- Reading files as UTF-8 (Issue #80) @danielperna84
Version 0.3.1 (2018-07-15)
- Fix SESAME / SESAME_TOTP_SECRET bug (Issue #103) @danielperna84

View file

@ -3749,8 +3749,8 @@ class RequestHandler(BaseHTTPRequestHandler):
if ENFORCE_BASEPATH and not is_safe_path(BASEPATH, filename):
raise OSError('Access denied.')
if os.path.isfile(os.path.join(BASEDIR.encode('utf-8'), filename)):
with open(os.path.join(BASEDIR.encode('utf-8'), filename)) as fptr:
content += fptr.read()
with open(os.path.join(BASEDIR.encode('utf-8'), filename), 'rb') as fptr:
content += fptr.read().decode('utf-8')
else:
content = "File not found"
except Exception as err: