mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 00:23:51 +01:00
Give a sensible error message if the filename is invalid UTF-8
This commit is contained in:
parent
5a9e0c3682
commit
c9cb354b58
2 changed files with 8 additions and 2 deletions
|
@ -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:
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue