markup utils: add clean_path()
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from django.conf import settings
|
||||
@ -84,3 +85,10 @@ def ensure_dir(dir):
|
||||
def set_file_perms(file):
|
||||
os.chmod(file, 0o664)
|
||||
shutil.chown(file, group='procat')
|
||||
|
||||
|
||||
def clean_path(path):
|
||||
"""Replace filesystem-hostile characters"""
|
||||
path = re.sub(r'[<>]', '', path)
|
||||
path = re.sub(r'[^\w@]', '_', path)
|
||||
return path
|
||||
|
||||
Reference in New Issue
Block a user