Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into zpublish
Browse files Browse the repository at this point in the history
  • Loading branch information
d-maurer committed Feb 20, 2024
2 parents fa44bc3 + 168963a commit 6b4f3c5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ https://github.com/zopefoundation/Zope/blob/4.x/CHANGES.rst
For details see
`#1197 <https://github.com/zopefoundation/Zope/pull/1197>`_.

- Fix ``Content-Disposition`` filename for clients without rfc6266 support.
(`#1198 <https://github.com/zopefoundation/Zope/pull/1198>`_)


5.9 (2023-11-24)
----------------
Expand Down
3 changes: 2 additions & 1 deletion src/ZPublisher/HTTPResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ def make_content_disposition(disposition, file_name):
#
# a special header has to be crafted
# also see https://tools.ietf.org/html/rfc6266#appendix-D
encoded_file_name = file_name.encode('us-ascii', errors='ignore')
encoded_file_name = file_name.encode(
'us-ascii', errors='ignore').decode()
header += f'; filename="{encoded_file_name}"'
quoted_file_name = quote(file_name)
header += f'; filename*=UTF-8\'\'{quoted_file_name}'
Expand Down
4 changes: 2 additions & 2 deletions src/ZPublisher/tests/testHTTPResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ def test_ascii(self):
def test_latin_one(self):
self.assertEqual(
make_content_disposition('inline', 'Dänemark.png'),
'inline; filename="b\'Dnemark.png\'"; filename*=UTF-8\'\'D%C3%A4nemark.png' # noqa: E501
'inline; filename="Dnemark.png"; filename*=UTF-8\'\'D%C3%A4nemark.png' # noqa: E501
)

def test_unicode(self):
Expand All @@ -1445,7 +1445,7 @@ def test_unicode(self):
"""
self.assertEqual(
make_content_disposition('inline', 'ıq.png'),
'inline; filename="b\'q.png\'"; filename*=UTF-8\'\'%C4%B1q.png'
'inline; filename="q.png"; filename*=UTF-8\'\'%C4%B1q.png'
)


Expand Down

0 comments on commit 6b4f3c5

Please sign in to comment.