Skip to content

Commit a313115

Browse files
committed
- issue2551257: add 'X-Content-Type-Options: nosniff' header for file download
when downloading an attached (user supplied file), make sure that an 'X-Content-Type-Options: nosniff' header is sent. Added test for header as well.
1 parent 34516f4 commit a313115

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Fixed:
7070
security issue with rest when using '*'.
7171
- issue2551263: In REST response expose rate limiting, sunset, allow
7272
HTTP headers to calling javascript.
73+
- issue2551257: When downloading an attached (user supplied file),
74+
make sure that an 'X-Content-Type-Options: nosniff' header is sent.
7375

7476
Features:
7577

roundup/cgi/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def inner_main(self):
846846
# exception handlers.
847847
self.determine_language()
848848
self.db.i18n = self.translator
849-
849+
self.setHeader("X-Content-Type-Options", "nosniff")
850850
self.serve_file(designator)
851851
except SendStaticFile as file:
852852
self.serve_static_file(str(file))

test/test_liveserver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,7 @@ def test_new_issue_with_file_upload(self):
11971197
# download file and verify content
11981198
f = session.get(self.url_base()+'/file%(file)s/text1.txt'%m.groupdict())
11991199
self.assertEqual(f.text, file_content)
1200+
self.assertEqual(f.headers["X-Content-Type-Options"], "nosniff")
12001201
print(f.text)
12011202

12021203
def test_new_file_via_rest(self):

0 commit comments

Comments
 (0)