mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
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:
|
||||
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 New Issue
Block a user