Created
December 24, 2010 16:08
-
-
Save shirou/754367 to your computer and use it in GitHub Desktop.
Secure filename it removes slash, null and all other un-secure strings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, re | |
_split = re.compile(r'[\0%s]' % re.escape(''.join( | |
[os.path.sep, os.path.altsep or '']))) | |
def secure_filename(path): | |
return _split.sub('', path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment