summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-06-30 10:31:59 +0100
committerErik Johnston <erik@matrix.org>2015-06-30 10:31:59 +0100
commit9beaedd1642673d36428dd796dda62f18a937c2a (patch)
treea0cf3fbef32d851abc0ae922a9a62646c292eae3 /synapse/util
parentAdd Content-Disposition headers to media repo v1 downloads (diff)
downloadsynapse-9beaedd1642673d36428dd796dda62f18a937c2a.tar.xz
Enforce ascii filenames for uploads
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/stringutils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/util/stringutils.py b/synapse/util/stringutils.py
index 52e66beaee..7a1e96af37 100644
--- a/synapse/util/stringutils.py
+++ b/synapse/util/stringutils.py
@@ -33,3 +33,12 @@ def random_string_with_symbols(length):
     return ''.join(
         random.choice(_string_with_symbols) for _ in xrange(length)
     )
+
+
+def is_ascii(s):
+    try:
+        s.encode("ascii")
+    except UnicodeDecodeError:
+        return False
+    else:
+        return True