##// END OF EJS Templates
file-store: handle custom extensions validation better, e.g lower case and both formats .exe / exe
bart -
r3972:c69ff9e6 default
parent child Browse files
Show More
@@ -143,13 +143,18 b' class LocalFileStorage(object):'
143 :param ext: extension to check
143 :param ext: extension to check
144 :param extensions: iterable of extensions to validate against (or self.extensions)
144 :param extensions: iterable of extensions to validate against (or self.extensions)
145 """
145 """
146 def normalize_ext(_ext):
147 if _ext.startswith('.'):
148 _ext = _ext[1:]
149 return _ext.lower()
146
150
147 extensions = extensions or self.extensions
151 extensions = extensions or self.extensions
148 if not extensions:
152 if not extensions:
149 return True
153 return True
150 if ext.startswith('.'):
154
151 ext = ext[1:]
155 ext = normalize_ext(ext)
152 return ext.lower() in extensions
156
157 return ext in [normalize_ext(x) for x in extensions]
153
158
154 def save_file(self, file_obj, filename, directory=None, extensions=None,
159 def save_file(self, file_obj, filename, directory=None, extensions=None,
155 extra_metadata=None, **kwargs):
160 extra_metadata=None, **kwargs):
General Comments 0
You need to be logged in to leave comments. Login now