Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24948 closed Bug (fixed)

BMP Image File treated as invalid

Reported by: jerzyk Owned by: Andriy Sokolovskiy
Component: Forms Version: 1.8
Severity: Release blocker Keywords: bmp, image
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


when assigning a .bmp (windows bitmap) image to an ImageField field, django reports error, responsible line, that raises an error is django/forms/ (to_python)

f.content_type = Image.MIME[image.format]

file is validated properly (opened, validated) and at the and, it's mime_type is detected by using a dictionary Image.MIME.

This dictionary is not documented and does not contain entries for BMP file, so it may be assumed that Django is using it's private api.

There are two options - push on Pillow to make this public API and fix an issue or use different method to find mime-type (e.g. python's standard mimetypes library)

Change History (5)

comment:1 by Tim Graham, 9 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

It's a regression in 1.8 (#10935), so qualifies for a backport. At least we could catch the exception and set f.content_type = None in that case.

comment:2 by Andriy Sokolovskiy, 9 years ago

Has patch: set
Owner: changed from nobody to Andriy Sokolovskiy
Status: newassigned

I think setting content_type to None will be enough.

comment:3 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In cf6ce279:

Fixed #24948 -- Fixed crash when uploading bitmap images in forms.ImageField

comment:5 by Tim Graham <timograham@…>, 9 years ago

In 8abe2d0:

[1.8.x] Fixed #24948 -- Fixed crash when uploading bitmap images in forms.ImageField

Backport of cf6ce279c7671a4c83c960c5c526f92679a4fac8 from master

Note: See TracTickets for help on using tickets.
Back to Top