Re: [Django] #33942: file validator - validating file with mime and magic numbers

1 view
Skip to first unread message

Django

unread,
Aug 19, 2022, 9:40:27 PM8/19/22
to django-...@googlegroups.com
#33942: file validator - validating file with mime and magic numbers
-------------------------------------+-------------------------------------
Reporter: Reza Shakeri | Owner: nobody
Type: New feature | Status: new
Component: File | Version: 4.0
uploads/storage |
Severity: Normal | Resolution:
Keywords: file-validator, | Triage Stage:
file, validator | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Reza Shakeri:

Old description:

> I want to add a file validator to Django using the native Python library
> called mimetypes [https://docs.python.org/3/library/mimetypes.html]
> There is a file validator in Django, but it only validates files using
> the extension, which is not very reliable. According to the
> documentation, I wrote a file validator that checks the magic numbers
> (mimes) of the files, and it is more reliable and reliable with It
> supports the use of native Python libraries and many mimes
>
> I wrote a file validator library using Python, which you can use using
> the link below and see its codes:
> [https://github.com/rzashakeri/file_validator]

New description:

I want to add a file validator to Django using the native Python library
called mimetypes [https://docs.python.org/3/library/mimetypes.html]
There is a file validator in Django, but it only validates files using the
extension, which is not very reliable. According to the documentation, I
wrote a file validator that checks the magic numbers (mimes) of the files,
and it is more reliable and reliable with It supports the use of native
Python libraries and many mimes, This file validator can check the size of
files in addition to mimes and validate both of them.

I wrote a file validator library using Python, which you can use using the
link below and see its codes:
[https://github.com/rzashakeri/file_validator]


file validator code :
https://github.com/rzashakeri/file_validator/blob/cfdb9cc90dba9708d895f18095a8177cd3392779/file_validator/django.py#L92

--

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

Django

unread,
Aug 19, 2022, 9:42:04 PM8/19/22
to django-...@googlegroups.com
#33942: file validator - validating file with mime and magic numbers
-------------------------------------+-------------------------------------
Reporter: rzashakeri | Owner: nobody

Type: New feature | Status: new
Component: File | Version: 4.0
uploads/storage |
Severity: Normal | Resolution:
Keywords: file-validator, | Triage Stage:
file, validator | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by rzashakeri:

Old description:

> I want to add a file validator to Django using the native Python library
> called mimetypes [https://docs.python.org/3/library/mimetypes.html]
> There is a file validator in Django, but it only validates files using
> the extension, which is not very reliable. According to the
> documentation, I wrote a file validator that checks the magic numbers
> (mimes) of the files, and it is more reliable and reliable with It

> supports the use of native Python libraries and many mimes, This file


> validator can check the size of files in addition to mimes and validate
> both of them.
>
> I wrote a file validator library using Python, which you can use using
> the link below and see its codes:
> [https://github.com/rzashakeri/file_validator]
>

New description:

I want to add a file validator to Django using the native Python library
called mimetypes [https://docs.python.org/3/library/mimetypes.html]
There is a file validator in Django, but it only validates files using the
extension, which is not very reliable. According to the documentation, I
wrote a file validator that checks the magic numbers (mimes) of the files,
and it is more reliable and reliable with It supports the use of native
Python libraries and many mimes, This file validator can check the size of
files in addition to mimes and validate both of them.

I wrote a file validator library using Python, which you can use using the
link below and see its codes:
[https://github.com/rzashakeri/file_validator]


The file validator code that I wrote myself and you can check:
https://github.com/rzashakeri/file_validator/blob/cfdb9cc90dba9708d895f18095a8177cd3392779/file_validator/django.py#L92

--

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

Django

unread,
Aug 19, 2022, 9:46:01 PM8/19/22
to django-...@googlegroups.com
#33942: file validator - validating file with mime and magic numbers
-------------------------------------+-------------------------------------
Reporter: Reza Shakeri | Owner: nobody

Type: New feature | Status: new
Component: File | Version: 4.0
uploads/storage |
Severity: Normal | Resolution:
Keywords: file-validator, | Triage Stage:
file, validator | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Reza Shakeri:

Old description:

> I want to add a file validator to Django using the native Python library
> called mimetypes [https://docs.python.org/3/library/mimetypes.html]
> There is a file validator in Django, but it only validates files using
> the extension, which is not very reliable. According to the
> documentation, I wrote a file validator that checks the magic numbers
> (mimes) of the files, and it is more reliable and reliable with It
> supports the use of native Python libraries and many mimes, This file
> validator can check the size of files in addition to mimes and validate
> both of them.
>
> I wrote a file validator library using Python, which you can use using
> the link below and see its codes:
> [https://github.com/rzashakeri/file_validator]
>

> The file validator code that I wrote myself and you can check:
> https://github.com/rzashakeri/file_validator/blob/cfdb9cc90dba9708d895f18095a8177cd3392779/file_validator/django.py#L92

New description:

I want to add a file validator to Django using the native Python library
called mimetypes [https://docs.python.org/3/library/mimetypes.html]
There is a file validator in Django, but it only validates files using the
extension, which is not very reliable. According to the documentation, I
wrote a file validator that checks the magic numbers (mimes) of the files

In addition to file extensions, and it is more reliable and reliable with


It supports the use of native Python libraries and many mimes, This file
validator can check the size of files in addition to mimes and validate
both of them.

I wrote a file validator library using Python, which you can use using the
link below and see its codes:
[https://github.com/rzashakeri/file_validator]

--

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

Django

unread,
Aug 22, 2022, 3:43:24 AM8/22/22
to django-...@googlegroups.com
#33942: file validator - validating file with mime and magic numbers
-------------------------------------+-------------------------------------
Reporter: Reza Shakeri | Owner: nobody
Type: New feature | Status: closed

Component: File | Version: 4.0
uploads/storage |
Severity: Normal | Resolution: wontfix

Keywords: file-validator, | Triage Stage:
file, validator | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => wontfix


Comment:

Hi Reza.

You've marked this as a new feature, so I guess you want to include this
in core. I'll say no at first pass, since complicating the built-in
validators isn't really on the agenda.
Folks are very able to create their own, as you've done here. There'd need
to be a consensus to include more logic here via a discussion on the
DevelopersMailingList.

You can also tell folks about your validator on the
[https://forum.djangoproject.com/c/projects/11 Show & Tell category on the
Django Forum]. (More generally see
TicketClosingReasons/UseSupportChannels).


Thanks.

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

Django

unread,
Aug 22, 2022, 4:03:12 AM8/22/22
to django-...@googlegroups.com
#33942: file validator - validating file with mime and magic numbers
-------------------------------------+-------------------------------------
Reporter: Reza Shakeri | Owner: nobody
Type: New feature | Status: closed
Component: File | Version: 4.0
uploads/storage |
Severity: Normal | Resolution: wontfix
Keywords: file-validator, | Triage Stage:
file, validator | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Reza Shakeri):

Thanks

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

Reply all
Reply to author
Forward
0 new messages