From b258e5d294d1684bfb144ab69b9010d0d810c936 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Wed, 17 Apr 2024 09:40:58 +0000 Subject: [PATCH] [FIX] http: force mimetype of .js files to text/javascript Previously, when the odoo server was running on some Windows installations, it was possible for javascript files loaded directly from the static folder of an addon to fail to run because the Content-Type header was set to text/plain instead of text/javascript. This is because the mimetypes module from the standard library honors the mimetypes from the OS, in the case of Windows it reads a key in the registry, which can be misconfigured to text/plain for .js files. This commit forces the mimetype of .js files to text/javascript to solve this issue. closes odoo/odoo#162313 X-original-commit: 64cbe389e698398eee93ebde9c61b2ee79756380 Signed-off-by: Julien Castiaux (juc) Signed-off-by: Samuel Degueldre (sad) --- odoo/http.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/odoo/http.py b/odoo/http.py index b7d65862861..1fa110294d9 100644 --- a/odoo/http.py +++ b/odoo/http.py @@ -200,6 +200,9 @@ mimetypes.add_type('application/x-font-ttf', '.ttf') mimetypes.add_type('image/webp', '.webp') # Add potentially wrong (detected on windows) svg mime types mimetypes.add_type('image/svg+xml', '.svg') +# this one can be present on windows with the value 'text/plain' which +# breaks loading js files from an addon's static folder +mimetypes.add_type('text/javascript', '.js') # To remove when corrected in Babel babel.core.LOCALE_ALIASES['nb'] = 'nb_NO'