From 7b2d8215e6ee852d18b6febae7ed4cd00078f253 Mon Sep 17 00:00:00 2001 From: CJ Date: Fri, 6 Jun 2014 09:55:20 -0400 Subject: [PATCH] Filename surrounded by double quotes. Chrome will give a Duplicate Header error if a file name has a comma in it, and the file name is not surrounded by double quotes. --- django_downloadview/response.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_downloadview/response.py b/django_downloadview/response.py index a9d97b6..3727934 100644 --- a/django_downloadview/response.py +++ b/django_downloadview/response.py @@ -77,9 +77,9 @@ def content_disposition(filename): ascii_filename = encode_basename_ascii(filename) utf8_filename = encode_basename_utf8(filename) if ascii_filename == utf8_filename: # ASCII only. - return "attachment; filename={ascii}".format(ascii=ascii_filename) + return "attachment; filename=\"{ascii}\"".format(ascii=ascii_filename) else: - return "attachment; filename={ascii}; filename*=UTF-8''{utf8}" \ + return "attachment; filename=\"{ascii}\"; filename*=UTF-8''\"{utf8}\"" \ .format(ascii=ascii_filename, utf8=utf8_filename)