From f413d155df1c8f8fc15877fb6d9f737472291ae3 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 31 May 2016 11:58:24 +0200 Subject: [PATCH] [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 --- openerp/http.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openerp/http.py b/openerp/http.py index e1a70fa72c6..07100e7444c 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -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.