This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mimetypes uses image/x-ms-bmp as the type for bmp files
Type: behavior Stage: resolved
Components: IO Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brma, jwatt, nitishch, r.david.murray
Priority: normal Keywords: easy, patch

Created on 2014-10-09 19:00 by brma, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4756 merged nitishch, 2017-12-08 10:01
Messages (9)
msg228892 - (view) Author: Brian Matthews (brma) Date: 2014-10-09 19:00
In the file mimetypes.py the mime type for bmp files should be image/bmp for IE8 and later. the problem is that if the content header for 'nosniff' is set, then the bmp file fails to display due to the incorrect mime type.
msg307653 - (view) Author: Jonathan Watt (jwatt) Date: 2017-12-05 10:40
Using image/x-ms-bmp because that's all that IE7 supports makes no sense. Chrome doesn't support image/x-ms-bmp (it only supports the official IANA type image/bmp), so if the concern is over browser support then it's clear that Chrome (the browser with the most market share) should trump IE7 (a browser that stopped getting support/security updates at the beginning of 2016, and has virtually no browser share).
msg307658 - (view) Author: Jonathan Watt (jwatt) Date: 2017-12-05 11:23
I should note that while Chrome will refuse to open an image/x-ms-bmp file directly, when loaded as an image embedded in a document (e.g. via HTML's <img>) then Chrome doesn't care what MIME type it has. It will sniff the image stream and detect from its contents that it is a BMP image and correctly render it.
msg307660 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-12-05 12:34
If image/bmp is now[*] the official IANA type, mimetypes should use that.  However, because this is a change with possible backward compatibility issues, it should probably only go into 3.7, but I'm open to arguments about that.

[*] The mimetypes module is very old and nobody specifically maintains it; we depend on user reports for updates to it, and obviously this one was overlooked.  Care to prepare a PR?
msg307661 - (view) Author: Jonathan Watt (jwatt) Date: 2017-12-05 13:18
> If image/bmp is now[*] the official IANA type

You can find image/bmp here:

https://www.iana.org/assignments/media-types/media-types.xhtml#image
msg307663 - (view) Author: Jonathan Watt (jwatt) Date: 2017-12-05 13:22
I'm unfamiliar with the Python contribution procedures. If it's simply a case of cloning from github.com and putting up a PR then I can do that. I'm overloaded currently though, so if it's more involved than that it may take me a while to figure things out.
msg307664 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-12-05 13:52
That's the basis, but its a bit more complicated than that (NEWS item, putting bpo-22589 in the issue title, the question of signing a CLA, though a CLA doesn't really matter for this kind of change IMO).  If you can't do it one of our core-mentorship volunteers will take care of it, I'm sure.
msg307848 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-12-08 12:48
New changeset ede157331b4f9e550334900b3b4de1c8590688de by R. David Murray (Nitish Chandra) in branch 'master':
bpo-22589 Changed MIME type of .bmp to "image/bmp" (#4756)
https://github.com/python/cpython/commit/ede157331b4f9e550334900b3b4de1c8590688de
msg307849 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-12-08 12:51
Thanks, nitishch.  As I said, I'm not going to backport this unless someone advances an argument in favor that discusses the possible backward compatibility issue.  (I'm not sure there are any significant ones, but someone needs to research it and present the results.)
History
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66779
2017-12-08 12:51:43r.david.murraysetstatus: open -> closed
versions: + Python 3.7, - Python 2.7
messages: + msg307849

resolution: fixed
stage: patch review -> resolved
2017-12-08 12:48:49r.david.murraysetmessages: + msg307848
2017-12-08 10:01:53nitishchsetnosy: + nitishch
2017-12-08 10:01:27nitishchsetkeywords: + patch
stage: patch review
pull_requests: + pull_request4659
2017-12-05 13:52:40r.david.murraysetkeywords: + easy

messages: + msg307664
2017-12-05 13:22:12jwattsetmessages: + msg307663
2017-12-05 13:18:56jwattsetmessages: + msg307661
2017-12-05 12:34:26r.david.murraysetnosy: + r.david.murray
messages: + msg307660
2017-12-05 11:23:04jwattsetmessages: + msg307658
2017-12-05 10:40:21jwattsetnosy: + jwatt
messages: + msg307653
2014-10-09 19:00:16brmacreate