Skip to content

Instantly share code, notes, and snippets.

@shirou
Created December 24, 2010 16:08
Show Gist options
  • Save shirou/754367 to your computer and use it in GitHub Desktop.
Save shirou/754367 to your computer and use it in GitHub Desktop.
Secure filename it removes slash, null and all other un-secure strings.
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