[Django] #24948: BMP Image File treated as invalid

8 views
Skip to first unread message

Django

unread,
Jun 7, 2015, 8:47:41 AM6/7/15
to django-...@googlegroups.com
#24948: BMP Image File treated as invalid
----------------------------+------------------------
Reporter: jerzyk | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Keywords: bmp, image
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------
when assigning a .bmp (windows bitmap) image to an ImageField field,
django reports error, responsible line, that raises an error is
django/forms/fields.py:695 (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)

--
Ticket URL: <https://code.djangoproject.com/ticket/24948>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 8, 2015, 3:34:03 PM6/8/15
to django-...@googlegroups.com
#24948: BMP Image File treated as invalid
---------------------------------+------------------------------------

Reporter: jerzyk | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: bmp, image | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_docs: => 0
* severity: Normal => Release blocker
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

It's a regression in 1.8 (#10935), so qualifies for a backport. At least
we could
[https://github.com/django/django/blob/9f825b9e28547b1310526c9be9fca9e6dbcd57e7/django/forms/fields.py#L686
catch the exception] and set `f.content_type = None` in that case.

--
Ticket URL: <https://code.djangoproject.com/ticket/24948#comment:1>

Django

unread,
Jun 16, 2015, 11:27:01 AM6/16/15
to django-...@googlegroups.com
#24948: BMP Image File treated as invalid
---------------------------------+------------------------------------
Reporter: jerzyk | Owner: coldmind
Type: Bug | Status: assigned
Component: Forms | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: bmp, image | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by coldmind):

* status: new => assigned
* owner: nobody => coldmind
* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/4869

I think setting `content_type` to None will be enough.

--
Ticket URL: <https://code.djangoproject.com/ticket/24948#comment:2>

Django

unread,
Jun 16, 2015, 12:22:22 PM6/16/15
to django-...@googlegroups.com
#24948: BMP Image File treated as invalid
-------------------------------------+-------------------------------------

Reporter: jerzyk | Owner: coldmind
Type: Bug | Status: assigned
Component: Forms | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: bmp, image | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/24948#comment:3>

Django

unread,
Jun 16, 2015, 2:38:23 PM6/16/15
to django-...@googlegroups.com
#24948: BMP Image File treated as invalid
-------------------------------------+-------------------------------------
Reporter: jerzyk | Owner: coldmind
Type: Bug | Status: closed
Component: Forms | Version: 1.8
Severity: Release blocker | Resolution: fixed

Keywords: bmp, image | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"cf6ce279c7671a4c83c960c5c526f92679a4fac8" cf6ce279]:
{{{
#!CommitTicketReference repository=""
revision="cf6ce279c7671a4c83c960c5c526f92679a4fac8"
Fixed #24948 -- Fixed crash when uploading bitmap images in
forms.ImageField
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24948#comment:4>

Django

unread,
Jun 16, 2015, 2:45:47 PM6/16/15
to django-...@googlegroups.com
#24948: BMP Image File treated as invalid
-------------------------------------+-------------------------------------
Reporter: jerzyk | Owner: coldmind
Type: Bug | Status: closed
Component: Forms | Version: 1.8

Severity: Release blocker | Resolution: fixed
Keywords: bmp, image | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"8abe2d0643a9ad9986e5b12644dbe0d0fc8b5f5d" 8abe2d0]:
{{{
#!CommitTicketReference repository=""
revision="8abe2d0643a9ad9986e5b12644dbe0d0fc8b5f5d"
[1.8.x] Fixed #24948 -- Fixed crash when uploading bitmap images in
forms.ImageField

Backport of cf6ce279c7671a4c83c960c5c526f92679a4fac8 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24948#comment:5>

Reply all
Reply to author
Forward
0 new messages