Add filename sanitiser

This commit is contained in:
Bo Maryniuk 2016-11-23 19:07:20 +01:00
parent 816b1d1977
commit 3ae086aff4

View File

@ -35,6 +35,16 @@ class InputSanitizer(object):
return text(value) return text(value)
@staticmethod
def filename(value):
'''
Remove everything that would affect paths in the filename
:param value:
:return:
'''
return re.sub('[^a-zA-Z0-9.-_ ]', '', os.path.basename(InputSanitizer.trim(value)))
clean = InputSanitizer() clean = InputSanitizer()