From aabbdc7339b9c2e1c10824ca2fc0a86419c46685 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 21 Sep 2015 15:30:05 +0200 Subject: [PATCH] [FIX] web: Safari, download of attachments with accents The structure `filename*=UTF-8` works in Safari, from release 6.2 (which is set as version 537 in the user_agent version). This structure has the advantage to handle the UTF-8 encoding, and therefore special characters, such as accents. Therefore, from this Safari release, we use the same format than other browser. For older releases, we use the format `filename=`, without UTF-8, ASCII encoded, replacing special characters by `?`. opw-649863 --- addons/web/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 6c6c9f1fe57..c598e224bba 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -451,8 +451,8 @@ def content_disposition(filename): version = int((request.httprequest.user_agent.version or '0').split('.')[0]) if browser == 'msie' and version < 9: return "attachment; filename=%s" % escaped - elif browser == 'safari': - return u"attachment; filename=%s" % filename + elif browser == 'safari' and version < 537: + return u"attachment; filename=%s" % filename.encode('ascii', 'replace') else: return "attachment; filename*=UTF-8''%s" % escaped