diff options
author | Erik Johnston <erik@matrix.org> | 2015-07-03 11:24:55 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-07-03 11:24:55 +0100 |
commit | 12b83f1a0d1e666b8dc629358a904613b23aac11 (patch) | |
tree | 78f7cef9678e1e6d12f72d8de988443c8a72fb5a /synapse/rest/media/v1/base_resource.py | |
parent | Enforce ascii filenames for uploads (diff) | |
download | synapse-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.py | 5 |
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, |