Give a sensible error message if the filename is invalid UTF-8
This commit is contained in:
parent
5a9e0c3682
commit
c9cb354b58
|
@ -155,7 +155,7 @@ class BaseMediaResource(Resource):
|
|||
if upload_name:
|
||||
upload_name = urlparse.unquote(upload_name)
|
||||
try:
|
||||
upload_name = upload_name.decode("utf-8");
|
||||
upload_name = upload_name.decode("utf-8")
|
||||
except UnicodeDecodeError:
|
||||
upload_name = None
|
||||
else:
|
||||
|
|
|
@ -86,7 +86,13 @@ class UploadResource(BaseMediaResource):
|
|||
|
||||
upload_name = request.args.get("filename", None)
|
||||
if upload_name:
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue