diff options
Diffstat (limited to 'addons/web/controllers/main.py')
| -rw-r--r-- | addons/web/controllers/main.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 91d178bc69c..03f73d8f947 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -28,6 +28,7 @@ import werkzeug.wsgi from collections import OrderedDict from werkzeug.urls import url_decode, iri_to_uri from xml.etree import ElementTree +import unicodedata import odoo @@ -1110,20 +1111,27 @@ class Binary(http.Controller): </script>""" args = [] for ufile in files: + + filename = ufile.filename + if request.httprequest.user_agent.browser == 'safari': + # Safari sends NFD UTF-8 (where é is composed by 'e' and [accent]) + # we need to send it the same stuff, otherwise it'll fail + filename = unicodedata.normalize('NFD', ufile.filename).encode('UTF-8') + try: attachment = Model.create({ - 'name': ufile.filename, + 'name': filename, 'datas': base64.encodestring(ufile.read()), - 'datas_fname': ufile.filename, + 'datas_fname': filename, 'res_model': model, 'res_id': int(id) }) except Exception: - args = args.append({'error': _("Something horrible happened")}) + args.append({'error': _("Something horrible happened")}) _logger.exception("Fail to upload attachment %s" % ufile.filename) else: args.append({ - 'filename': ufile.filename, + 'filename': filename, 'mimetype': ufile.content_type, 'id': attachment.id }) |
