From 0bff85f82a33879331a0cc2abca18acf0e492790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 16 Nov 2016 04:44:29 +0100 Subject: [PATCH] misc: don't force PDF attachments to be downloaded (#13977) It made sense when browsers were riddled by the acrobat plugin and it had to be forcefully avoided but nowadays sanity has returned and getting the PDF displayed in the browser window is a better choice. --- tests/test_form_pages.py | 4 +++- wcs/forms/common.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_form_pages.py b/tests/test_form_pages.py index 09c60be..b96b86c 100644 --- a/tests/test_form_pages.py +++ b/tests/test_form_pages.py @@ -2310,9 +2310,11 @@ def test_formdata_generated_document_odt_to_pdf_download(pub): assert resp.location.endswith('/template.pdf') resp = resp.follow() assert resp.content_type == 'application/pdf' + content_disposition = resp._headers['content-disposition'] + assert len(content_disposition.split(';')) == 2 + assert content_disposition.split(';')[0] == 'inline' assert resp.body.startswith('%PDF-') - @pytest.mark.skipif(transform_to_pdf is None, reason='libreoffice not found') def test_formdata_generated_document_odt_to_pdf_download_push_to_portfolio(pub, fargo_url, fargo_secret, caplog): diff --git a/wcs/forms/common.py b/wcs/forms/common.py index a90d483..95d8b24 100644 --- a/wcs/forms/common.py +++ b/wcs/forms/common.py @@ -70,7 +70,7 @@ class FileDirectory(Directory): if file.charset: response.set_charset(file.charset) if file.base_filename: - if file.content_type.startswith('image/'): + if file.content_type.startswith('image/') or file.content_type == 'application/pdf': response.set_header( 'content-disposition', 'inline; filename="%s"' % file.base_filename) else: -- 2.10.2