pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
https://flask-admin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
5.78k stars 1.57k forks source link

Add this to upload.py #353

Closed dpgaspar closed 10 years ago

dpgaspar commented 10 years ago

Hello,

you could change upload.py

from:

if not allowed_extensions: allowed_extensions = ('gif', 'jpg', 'jpeg', 'png', 'tiff')

to this:

if not allowed_extensions: allowed_extensions = ('gif', 'jpg', 'jpeg', 'png', 'tiff','GIF','JPG','JPEG','PNG','TIFF')

Excelent work your all doing. Best of luck.

pedrospdc commented 10 years ago

lol

https://github.com/mrjoes/flask-admin/blob/master/flask_admin/form/upload.py#L175

return ('.' in filename and filename.rsplit('.', 1)[1].lower() in self.allowed_extensions)

dpgaspar commented 10 years ago

I mean replacing this:

https://github.com/mrjoes/flask-admin/blob/master/flask_admin/form/upload.py#L337

because it's case sensitive.

mrjoes commented 10 years ago

As @pedrospdc mentioned, check is case-insensitive.

dpgaspar commented 10 years ago

Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

a = ('jpg','tiff') 'jpg' in a True 'JPG' in a False

mrjoes commented 10 years ago

It does not check extension using in, @pedrospdc linked code that does the check:

return ('.' in filename and
filename.rsplit('.', 1)[1].lower() in self.allowed_extensions)

As you can see, it checks if there's a dot in the filename, then gets part after the dot, changes to lowercase and verifies that it is in allowed_extensions.

So, check itself is case insensitive and adding uppercase variations of extensions to allowed_extensions won't do anything.

dpgaspar commented 10 years ago

Sorry, but it must be my confusion... but i don't see that code on this:

https://github.com/mrjoes/flask-admin/blob/master/flask_admin/form/upload.py#L175

and yes:

return ('.' in filename and filename.rsplit('.', 1)[1].lower() in self.allowed_extensions)

Is a better solution. If it's all right just forget it, just trying to help.