From: Jan Szejko Date: Mon, 16 Jan 2017 09:13:54 +0000 (+0100) Subject: workaround bug in django (newlines in http headers, https://code.djangoproject.com... X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/4d579bfcf20ca69d142c3bcc9eb96feb72888d63?ds=sidebyside workaround bug in django (newlines in http headers, https://code.djangoproject.com/ticket/20889) --- diff --git a/stage2/views.py b/stage2/views.py index 7f3422e..6b04a57 100644 --- a/stage2/views.py +++ b/stage2/views.py @@ -54,7 +54,8 @@ def upload(request, assignment_id, participant_id, key): def attachment_download(attachment): response = HttpResponse(content_type='application/force-download') response.write(attachment.file.read()) - response['Content-Disposition'] = 'attachment; filename="%s"' % attachment.filename() + base, ext = attachment.filename().rsplit('.', 1) + response['Content-Disposition'] = 'attachment; filename="%s.%s"' % (base[:10].replace('\n', ''), ext) response['Content-Length'] = response.tell() return response