Projet

Général

Profil

0001-misc-don-t-force-PDF-attachments-to-be-downloaded-13.patch

Frédéric Péters, 16 novembre 2016 04:49

Télécharger (2,01 ko)

Voir les différences:

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(-)
tests/test_form_pages.py
2310 2310
    assert resp.location.endswith('/template.pdf')
2311 2311
    resp = resp.follow()
2312 2312
    assert resp.content_type == 'application/pdf'
2313
    content_disposition = resp._headers['content-disposition']
2314
    assert len(content_disposition.split(';')) == 2
2315
    assert content_disposition.split(';')[0] == 'inline'
2313 2316
    assert resp.body.startswith('%PDF-')
2314 2317

  
2315

  
2316 2318
@pytest.mark.skipif(transform_to_pdf is None, reason='libreoffice not found')
2317 2319
def test_formdata_generated_document_odt_to_pdf_download_push_to_portfolio(pub, fargo_url,
2318 2320
                                                                           fargo_secret, caplog):
wcs/forms/common.py
70 70
        if file.charset:
71 71
            response.set_charset(file.charset)
72 72
        if file.base_filename:
73
            if file.content_type.startswith('image/'):
73
            if file.content_type.startswith('image/') or file.content_type == 'application/pdf':
74 74
                response.set_header(
75 75
                        'content-disposition', 'inline; filename="%s"' % file.base_filename)
76 76
            else:
77
-