[FIX] openerp: force Odoo to serve svg with mimetype image/svg+xml

Odoo serves files based on the mimetype imported with python module Mimetype.
In some case, mimetype on windows for svg is undefined or misconfigured and
the svg is returned as text/plain (and so xml and not img).

This commit overrides the default mimetype to render .svg file with mimetype
'image/svg+xml'.

It is similar to add/override the key from windows registry with:
```
[HKEY_CLASSES_ROOT\.svg]
@="svgfile"
"Content Type"="image/svg+xml"
```
The advantage to override it in Odoo, is to be sure that even if this key has
been updated or deleted by a cleaner software or malware, Odoo continue to work

This closes odoo/odoo#12150, closes odoo/odoo#9061, closes odoo/odoo#9118
This commit is contained in:
Jeremy Kersten
2016-05-31 14:14:30 +02:00
parent fe511f18e1
commit f413d155df
+2
View File
@@ -1376,6 +1376,8 @@ def session_gc(session_store):
mimetypes.add_type('application/font-woff', '.woff')
mimetypes.add_type('application/vnd.ms-fontobject', '.eot')
mimetypes.add_type('application/x-font-ttf', '.ttf')
# Add potentially missing (detected on windows) svg mime types
mimetypes.add_type('image/svg+xml', '.svg')
class Response(werkzeug.wrappers.Response):
""" Response object passed through controller route chain.