mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add filename sanitiser
This commit is contained in:
parent
816b1d1977
commit
3ae086aff4
1 changed files with 10 additions and 0 deletions
|
@ -35,6 +35,16 @@ class InputSanitizer(object):
|
|||
|
||||
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()
|
||||
|
|
Loading…
Add table
Reference in a new issue