From 8194e2cb80def6b1943a88d57fdc66c8eddc1660 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Wed, 16 May 2018 09:11:42 +0200 Subject: [PATCH] [FIX] web: correctly handle admin svg images in channel When posting an svg image, Odoo tries to resize it for thumbnailing (like any image). However this is of no interest since this is a vectorial file format, and furthermore it distastefully makes the image library Pillow crash, since it only supports raster formats. The result would be a broken thumbnail instead of the image itself. By not setting the thumbnail size if the mimetype contains svg, we ignore the thumbnailing altogether. Note that this only applies to the admin user, as otherwise the file is treated as binary and thus no thumbnailing occurs anyway. opw 1841153 --- addons/web/controllers/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index d6c007f8f83..c0b412411e3 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1047,8 +1047,12 @@ class Binary(http.Controller): elif status != 200 and download: return request.not_found() - height = int(height or 0) - width = int(width or 0) + if headers and dict(headers).get('Content-Type', '') == 'image/svg+xml': # we shan't resize svg images + height = 0 + width = 0 + else: + height = int(height or 0) + width = int(width or 0) if crop and (width or height): content = crop_image(content, type='center', size=(width, height), ratio=(1, 1))