diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2020-05-18 10:45:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 10:45:30 +0100 |
commit | 4d1afb1dfe678898322479e229b3d51cc33c3fd2 (patch) | |
tree | 0aa0009fc0f1c8ca09f4379810ac71a34e0ee775 /synapse/rest | |
parent | fix mypy for tests/replication (#7518) (diff) | |
parent | changelog (diff) | |
download | synapse-4d1afb1dfe678898322479e229b3d51cc33c3fd2.tar.xz |
Merge pull request #7519 from matrix-org/rav/kill_py2_code
Kill off some old python 2 code
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/media/v1/_base.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/synapse/rest/media/v1/_base.py b/synapse/rest/media/v1/_base.py index 503f2bed98..3689777266 100644 --- a/synapse/rest/media/v1/_base.py +++ b/synapse/rest/media/v1/_base.py @@ -17,7 +17,6 @@ import logging import os -from six import PY3 from six.moves import urllib from twisted.internet import defer @@ -324,23 +323,15 @@ def get_filename_from_headers(headers): upload_name_utf8 = upload_name_utf8[7:] # We have a filename*= section. This MUST be ASCII, and any UTF-8 # bytes are %-quoted. - if PY3: - try: - # Once it is decoded, we can then unquote the %-encoded - # parts strictly into a unicode string. - upload_name = urllib.parse.unquote( - upload_name_utf8.decode("ascii"), errors="strict" - ) - except UnicodeDecodeError: - # Incorrect UTF-8. - pass - else: - # On Python 2, we first unquote the %-encoded parts and then - # decode it strictly using UTF-8. - try: - upload_name = urllib.parse.unquote(upload_name_utf8).decode("utf8") - except UnicodeDecodeError: - pass + try: + # Once it is decoded, we can then unquote the %-encoded + # parts strictly into a unicode string. + upload_name = urllib.parse.unquote( + upload_name_utf8.decode("ascii"), errors="strict" + ) + except UnicodeDecodeError: + # Incorrect UTF-8. + pass # If there isn't check for an ascii name. if not upload_name: |