summaryrefslogtreecommitdiffstats
path: root/core/utils.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-09-13 18:46:10 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-09-13 18:46:10 +0300
commit70dd61b2baeb9de85d7f6e1816df9368a5b18e3f (patch)
tree6ae82e1c576a28229d46b5e33e81016b3a6a5349 /core/utils.py
parent33a485d207d1ea6b8bf8cc3c67231dccc8778af2 (diff)
downloadtroggle-70dd61b2baeb9de85d7f6e1816df9368a5b18e3f.tar.gz
troggle-70dd61b2baeb9de85d7f6e1816df9368a5b18e3f.tar.bz2
troggle-70dd61b2baeb9de85d7f6e1816df9368a5b18e3f.zip
sanitize filenames
Diffstat (limited to 'core/utils.py')
-rw-r--r--core/utils.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/utils.py b/core/utils.py
index 9144113..17bd953 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -44,6 +44,11 @@ except:
pass
+def sanitize_name(name):
+ """Filenames sould not caontain these characters as then the system barf when it tries to use them in URLs
+ """
+ return name.replace("#","-").replace("?","=").replace("&","+").replace(":","^")
+
def get_process_memory():
usage = resource.getrusage(resource.RUSAGE_SELF)
return usage[2] / 1024.0