Closed dpgaspar closed 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)
I mean replacing this:
https://github.com/mrjoes/flask-admin/blob/master/flask_admin/form/upload.py#L337
because it's case sensitive.
As @pedrospdc mentioned, check is case-insensitive.
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
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.
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.
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.