UTF-8 Javascript files served by the SharedDataMiddleware do not contain a charset in the Content-Type response header. This leads to issues of javascript interpreted as US-ASCII by browsers (posativ/isso#607).
I am not familiar with the codebase, but would it be possible to call get_content_type? I tried to modify it myself, but I don't know where to get the encoding from inside SharedDataMiddleware.
My problem is solved when I hardcode 'utf-8' as charset:
Description
UTF-8 Javascript files served by the SharedDataMiddleware do not contain a charset in the
Content-Type
response header. This leads to issues of javascript interpreted as US-ASCII by browsers (posativ/isso#607).Current
Expected
The mime type is deducted by using python's mimetypes module and the filename:
werkzeug/src/werkzeug/middleware/shared_data.py
Lines 256 to 257 in aa9676f
It is sent without appending an encoding:
werkzeug/src/werkzeug/middleware/shared_data.py
Line 281 in aa9676f
Other usages seem to suggest that a call to
get_content_type
is necessary to append the charset, if applicable:werkzeug/src/werkzeug/wrappers/common_descriptors.py
Line 146 in e76aac8
Possible solutions
I am not familiar with the codebase, but would it be possible to call
get_content_type
? I tried to modify it myself, but I don't know where to get the encoding from insideSharedDataMiddleware
.My problem is solved when I hardcode 'utf-8' as charset:
The text was updated successfully, but these errors were encountered: