summaryrefslogtreecommitdiff
path: root/addons/web/controllers
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-05-24 13:19:19 +0200
committerChristophe Simonis <chs@odoo.com>2016-05-24 13:19:19 +0200
commitfac4cc7006e5d72a5f6ee261e8a7422c78f5e6fb (patch)
treefacc8cb60bcd0f1d0536f6f004d05aefcf444fc7 /addons/web/controllers
parentfacb6644839c2120296e0845b8f780cb9998e34e (diff)
parentf8e6bb73b3aed541fd96e28ec0382ea9964a1db7 (diff)
[MERGE] forward port of branch saas-9 up to f8e6bb7
Diffstat (limited to 'addons/web/controllers')
-rw-r--r--addons/web/controllers/main.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 9d9f90a89df..18a9d55e601 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -4,6 +4,7 @@ import base64
import csv
import functools
import glob
+import imghdr
import itertools
import jinja2
import logging
@@ -1067,7 +1068,8 @@ class Binary(http.Controller):
'/logo.png',
], type='http', auth="none", cors="*")
def company_logo(self, dbname=None, **kw):
- imgname = 'logo.png'
+ imgname = 'logo'
+ imgext = '.png'
placeholder = functools.partial(get_resource_path, 'web', 'static', 'src', 'img')
uid = None
if request.session.db:
@@ -1080,7 +1082,7 @@ class Binary(http.Controller):
uid = openerp.SUPERUSER_ID
if not dbname:
- response = http.send_file(placeholder(imgname))
+ response = http.send_file(placeholder(imgname + imgext))
else:
try:
# create an empty registry
@@ -1094,12 +1096,14 @@ class Binary(http.Controller):
""", (uid,))
row = cr.fetchone()
if row and row[0]:
- image_data = StringIO(str(row[0]).decode('base64'))
- response = http.send_file(image_data, filename=imgname, mtime=row[1])
+ image_base64 = str(row[0]).decode('base64')
+ image_data = StringIO(image_base64)
+ imgext = '.' + (imghdr.what(None, h=image_base64) or 'png')
+ response = http.send_file(image_data, filename=imgname + imgext, mtime=row[1])
else:
response = http.send_file(placeholder('nologo.png'))
except Exception:
- response = http.send_file(placeholder(imgname))
+ response = http.send_file(placeholder(imgname + imgext))
return response