summary refs log tree commit diff
path: root/synapse/rest/media/v1/base_resource.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-07-03 11:24:55 +0100
committerErik Johnston <erik@matrix.org>2015-07-03 11:24:55 +0100
commit12b83f1a0d1e666b8dc629358a904613b23aac11 (patch)
tree78f7cef9678e1e6d12f72d8de988443c8a72fb5a /synapse/rest/media/v1/base_resource.py
parentEnforce ascii filenames for uploads (diff)
downloadsynapse-12b83f1a0d1e666b8dc629358a904613b23aac11.tar.xz
If user supplies filename in URL when downloading from media repo, use that name in Content Disposition
Diffstat (limited to 'synapse/rest/media/v1/base_resource.py')
-rw-r--r--synapse/rest/media/v1/base_resource.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/synapse/rest/media/v1/base_resource.py b/synapse/rest/media/v1/base_resource.py
index 1b7517e2f0..c43ae0314b 100644
--- a/synapse/rest/media/v1/base_resource.py
+++ b/synapse/rest/media/v1/base_resource.py
@@ -42,7 +42,10 @@ def parse_media_id(request):
         # This allows users to append e.g. /test.png to the URL. Useful for
         # clients that parse the URL to see content type.
         server_name, media_id = request.postpath[:2]
-        return (server_name, media_id)
+        if len(request.postpath) > 2 and is_ascii(request.postpath[-1]):
+            return server_name, media_id, request.postpath[-1]
+        else:
+            return server_name, media_id, None
     except:
         raise SynapseError(
             404,