diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-04-23 17:59:59 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-04-23 17:59:59 +0200 |
| commit | 3ab25b60bc5e13a91a518f5effd46a28b026a8f7 (patch) | |
| tree | 4ab971eb25736469897d13ea10e758c9caea9b01 /addons/web/controllers/main.py | |
| parent | 30490cae89a3c528c01f470e828f11853df25126 (diff) | |
| parent | cae950e826292f5246b73eeb5d85cb1d47c76978 (diff) | |
[MERGE] forward port branch saas-15 up to cae950e8262
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 }) |
