-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix Content-Disposition in media repository #4176
Conversation
.coveragerc
Outdated
@@ -0,0 +1,12 @@ | |||
[run] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, but could you put the coverage stuff in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Isn't that #4180?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, #4180 :) (If we merge that first then this squashed merge won't have it, which is why I didn't bother removing it)
I'm assuming this is meant to fix #4160 |
Co-Authored-By: hawkowl <[email protected]>
…rg/synapse into hawkowl/py3-content-disposition
pending merge of #4180 then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm apart from some nits about comments
if not content_disposition[0]: | ||
return | ||
|
||
params = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd find a comment which documents the type of this useful. It seems to be a map from a unicode
to a bytes
?
(Edit: I see that you kinda document this below, but I'd find it clearer here. Also the terms "decoded" and "unencoded" are pretty overloaded and unclear here)
synapse/rest/media/v1/_base.py
Outdated
upload_name_utf8 = upload_name_utf8[7:] | ||
if PY3: | ||
try: | ||
# We have a filename*= section. This MUST be ASCII, and any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Half of this comment seems to apply to PY2 as well as PY3, so could it be pulled up? Also "quoted" doesn't mean much to me, even if that's what urllib calls it. Can we call it "%-encoded" or "%-escaped" or something?
synapse/rest/media/v1/_base.py
Outdated
if PY3: | ||
try: | ||
# We have a filename*= section. This MUST be ASCII, and any | ||
# UTF-8 bytes are quoted. Once it is decoded, we can then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"decoded" is unclear to me. Can we say something like:
First decode the ascii bytes to a str, then we can %-decode it safely
synapse/rest/media/v1/_base.py
Outdated
# Incorrect UTF-8. | ||
pass | ||
else: | ||
# On Python 2, we can unquote it directly, and then decode it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# On Python 2, we can unquote it directly, and then decode it | |
# On Python 2, we can %-decode it directly, and then decode the utf8 bytes to a unicode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
No description provided.