[Django] #21548: Add the ability to limit file extensions for ImageField and FileField

24 views
Skip to first unread message

Django

unread,
Dec 2, 2013, 3:49:06 PM12/2/13
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
---------------------------------------+------------------------
Reporter: timo | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+------------------------
ImageField/FileField could have an optional extension whitelist. This
could default to being empty for both fields to be totally backwards
compatible, or could have sensible defaults for the ImageField based on
the file types supported by PIL/low. The documentation should warn that
you should not rely on file extensions to determine the actual content
type of files.

There are probably some existing implementations we could borrow from, for
example:

https://djangosnippets.org/snippets/977/

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

Django

unread,
Apr 14, 2014, 2:03:20 PM4/14/14
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+------------------------------------
Reporter: timo | Owner: jfilipe
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by jfilipe):

* owner: nobody => jfilipe
* status: new => assigned


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

Django

unread,
Apr 14, 2014, 2:05:46 PM4/14/14
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+------------------------------------
Reporter: timo | Owner: jfilipe
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by jfilipe):

I have a work in progress PR here:
https://github.com/jfilipe/django/pull/2

Wanted to get some feedback on the approach before I added some docs.

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

Django

unread,
Apr 14, 2014, 2:06:32 PM4/14/14
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+------------------------------------
Reporter: timo | Owner: jfilipe
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by jfilipe):

* has_patch: 0 => 1


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

Django

unread,
Jun 5, 2014, 6:51:30 PM6/5/14
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+------------------------------------
Reporter: timo | Owner: jfilipe
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* needs_docs: 0 => 1


Comment:

Hi, I left a comment for improvement on the PR, although it's better to
open a PR against Django itself instead of your fork.

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

Django

unread,
Jun 18, 2014, 5:51:37 AM6/18/14
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+------------------------------------
Reporter: timo | Owner: jfilipe
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

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

Comment (by anubhav9042):

The patch looks good but the validator must be like others as Tim
suggested on your PR.
Also adding it to `ImageField` by default sounds good. I hope we can fix
#18543 with it.

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

Django

unread,
Jun 18, 2014, 5:54:49 AM6/18/14
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+------------------------------------
Reporter: timo | Owner: jfilipe
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

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

* cc: anubhav9042@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:6>

Django

unread,
Mar 26, 2016, 4:16:06 PM3/26/16
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+----------------------------------------
Reporter: timo | Owner: berkerpeksag

Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+----------------------------------------
Changes (by berkerpeksag):

* cc: berker.peksag@… (added)
* needs_better_patch: 1 => 0
* owner: jfilipe => berkerpeksag
* needs_docs: 1 => 0


Comment:

Pull request: https://github.com/django/django/pull/6343

Changes:

* Added two validators: FileExtensionValidator and validate_image_file
(this one uses FileExtensionValidator with default values from
PIL.Image.EXTENSION).
* Added validate_image_file to ImageField as a default validator.
* Added tests for FileExtensionValidator, model and form validations.
* Added documentation and release notes. I probably need to add some note
for ImageField docs too.

--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:7>

Django

unread,
Apr 8, 2016, 12:35:17 PM4/8/16
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+----------------------------------------
Reporter: timo | Owner: berkerpeksag
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


Comment:

Left some comments for improvement.

--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:8>

Django

unread,
Jun 29, 2016, 4:44:28 PM6/29/16
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+---------------------------------------------

Reporter: timo | Owner: berkerpeksag
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | 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):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:9>

Django

unread,
Jun 30, 2016, 9:12:05 AM6/30/16
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+---------------------------------------------
Reporter: timo | Owner: berkerpeksag
Type: New feature | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed

Keywords: | 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:"12b4280444b58c94197255655e284e4103fe00a9" 12b4280]:
{{{
#!CommitTicketReference repository=""
revision="12b4280444b58c94197255655e284e4103fe00a9"
Fixed #21548 -- Added FileExtensionValidator and
validate_image_file_extension.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:10>

Django

unread,
Jul 2, 2016, 9:47:05 AM7/2/16
to django-...@googlegroups.com
#21548: Add the ability to limit file extensions for ImageField and FileField
-----------------------------+---------------------------------------------
Reporter: timo | Owner: berkerpeksag
Type: New feature | Status: closed
Component: Forms | Version: master

Severity: Normal | Resolution: fixed
Keywords: | 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 Baptiste Mispelon <bmispelon@…>):

In [changeset:"a9215b7c36bff232bcc9416309726290dc74a9e8" a9215b7c]:
{{{
#!CommitTicketReference repository=""
revision="a9215b7c36bff232bcc9416309726290dc74a9e8"
Refs #21548 -- Skipped tests that rely on pillow when it's not installed
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:11>

Reply all
Reply to author
Forward
0 new messages