summary refs log tree commit diff
path: root/synapse/rest/media/v1/upload_resource.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-07-08 15:37:33 +0100
committerErik Johnston <erik@matrix.org>2015-07-08 15:37:33 +0100
commit304343f4d7502d65ff7977df466209ef4702b90c (patch)
tree0eb1002013d40ef65dcd82e630859c467b3e6ec7 /synapse/rest/media/v1/upload_resource.py
parentAdd a cache to fetching of receipt streams (diff)
parentMerge pull request #197 from matrix-org/mjark/missing_regex_group (diff)
downloadsynapse-304343f4d7502d65ff7977df466209ef4702b90c.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/receipts
Diffstat (limited to 'synapse/rest/media/v1/upload_resource.py')
-rw-r--r--synapse/rest/media/v1/upload_resource.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/upload_resource.py b/synapse/rest/media/v1/upload_resource.py
index cc571976a5..cdd1d44e07 100644
--- a/synapse/rest/media/v1/upload_resource.py
+++ b/synapse/rest/media/v1/upload_resource.py
@@ -15,7 +15,7 @@
 
 from synapse.http.server import respond_with_json, request_handler
 
-from synapse.util.stringutils import random_string
+from synapse.util.stringutils import random_string, is_ascii
 from synapse.api.errors import SynapseError
 
 from twisted.web.server import NOT_DONE_YET
@@ -84,6 +84,12 @@ class UploadResource(BaseMediaResource):
                 code=413,
             )
 
+        upload_name = request.args.get("filename", None)
+        if upload_name:
+            upload_name = upload_name[0]
+            if upload_name and not is_ascii(upload_name):
+                raise SynapseError(400, "filename must be ascii")
+
         headers = request.requestHeaders
 
         if headers.hasHeader("Content-Type"):
@@ -99,7 +105,7 @@ class UploadResource(BaseMediaResource):
         # TODO(markjh): parse content-dispostion
 
         content_uri = yield self.create_content(
-            media_type, None, request.content.read(),
+            media_type, upload_name, request.content.read(),
             content_length, auth_user
         )