1
0
mirror of synced 2024-09-23 19:08:21 +02:00

Force decoding JSX files as utf-8 regardless of the OS locale and settings.

This commit is contained in:
Jennifer Taylor 2020-08-18 21:54:48 +00:00
parent 19c7de499d
commit 0bb19948be

View File

@ -133,10 +133,9 @@ def jsx(filename: str) -> Response:
namespace = f'{mtime}.{jsxfile}'
jsx = g.cache.get(namespace)
if jsx is None:
transformer = JSXTransformer()
f = open(jsxfile, 'r')
jsx = transformer.transform_string(f.read())
f.close()
with open(jsxfile, 'rb') as f:
transformer = JSXTransformer()
jsx = transformer.transform_string(f.read().decode('utf-8'))
# Set the cache to one year, since we namespace on this file's update time
g.cache.set(namespace, jsx, timeout=86400 * 365)
return Response(jsx, mimetype='application/javascript')