diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-08-26 17:27:23 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-08-26 17:27:23 +0100 |
commit | c9cb354b58972b9e0e91cd6d6398e9bb02f7b967 (patch) | |
tree | 96518f02f3b845794c270da3c026d0d157dd52e2 /synapse/rest/media/v1/upload_resource.py | |
parent | Handle unicode filenames given when downloading or received over federation (diff) | |
download | synapse-c9cb354b58972b9e0e91cd6d6398e9bb02f7b967.tar.xz |
Give a sensible error message if the filename is invalid UTF-8
Diffstat (limited to 'synapse/rest/media/v1/upload_resource.py')
-rw-r--r-- | synapse/rest/media/v1/upload_resource.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/rest/media/v1/upload_resource.py b/synapse/rest/media/v1/upload_resource.py index 21d8fb9ce9..031bfa80f8 100644 --- a/synapse/rest/media/v1/upload_resource.py +++ b/synapse/rest/media/v1/upload_resource.py @@ -86,7 +86,13 @@ class UploadResource(BaseMediaResource): upload_name = request.args.get("filename", None) if upload_name: - upload_name = upload_name[0].decode('UTF-8') + try: + upload_name = upload_name[0].decode('UTF-8') + except UnicodeDecodeError: + raise SynapseError( + msg="Invalid UTF-8 filename parameter: %r" % (upload_name), + code=400, + ) headers = request.requestHeaders |