Skip to content

Commit 9b14a14

Browse files
committed
Remove image special-casing
1 parent 9326ff9 commit 9b14a14

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

pypi_view/app.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,6 @@
5252
'video/',
5353
)
5454

55-
# Mime types which should be displayed inline in the browser, as opposed to
56-
# being downloaded. This is used to populate the Content-Disposition header.
57-
# Only binary MIMEs need to be whitelisted here, since detected non-binary
58-
# files are always inline.
59-
INLINE_DISPLAY_MIME_WHITELIST = (
60-
'application/pdf',
61-
'audio/',
62-
'image/',
63-
'video/',
64-
)
65-
6655

6756
install_root = os.path.dirname(__file__)
6857

@@ -290,16 +279,8 @@ async def transfer_file():
290279
# (1) Reasonable-length text: render syntax highlighted in HTML
291280
# (2) Extremely long text: don't render, just show error and offer
292281
# link to the raw file
293-
# (3) Binary file that browsers can display (e.g. image): render raw
294-
# (4) Binary file that browsers cannot display (e.g. tarball): don't
295-
# render, just show warning and link to the raw file
296-
#
297-
# Note that except for images, the file extension isn't too useful to
298-
# determine the actual content since there are lots of files without
299-
# extensions (and lots of extensions not recognized by `mimetypes`).
300-
if mimetype is not None and mimetype.startswith(INLINE_DISPLAY_MIME_WHITELIST):
301-
# Case 3: render binary
302-
return _transfer_raw()
282+
# (3) Binary file: don't render, just show warning and link to the raw
283+
# file
303284

304285
# Figure out if it looks like text or not.
305286
async with package.open_from_archive(archive_path) as f:
@@ -354,7 +335,7 @@ async def transfer_file():
354335
},
355336
)
356337

357-
# Case 4: link to binary
338+
# Case 3: link to binary
358339
return templates.TemplateResponse(
359340
'package_file_archive_path.html',
360341
{

0 commit comments

Comments
 (0)