New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Content-Disposition in media repository #4176

Merged
merged 12 commits into from Nov 15, 2018

Conversation

Projects
None yet
3 participants
@hawkowl
Copy link
Contributor

hawkowl commented Nov 12, 2018

No description provided.

hawkowl added some commits Nov 7, 2018

fix

@hawkowl hawkowl changed the base branch from master to develop Nov 12, 2018

fix

@hawkowl hawkowl requested a review from matrix-org/synapse-core Nov 12, 2018

hawkowl added some commits Nov 12, 2018

.coveragerc Outdated
@@ -0,0 +1,12 @@
[run]

This comment has been minimized.

@richvdh

richvdh Nov 13, 2018

Member

sorry, but could you put the coverage stuff in a separate PR?

This comment has been minimized.

@richvdh

richvdh Nov 14, 2018

Member

bump.

This comment has been minimized.

@erikjohnston

erikjohnston Nov 14, 2018

Member

(Isn't that #4180?)

This comment has been minimized.

@hawkowl

hawkowl Nov 14, 2018

Contributor

yes, #4180 :) (If we merge that first then this squashed merge won't have it, which is why I didn't bother removing it)

Show resolved Hide resolved synapse/rest/media/v1/_base.py Outdated
Show resolved Hide resolved synapse/rest/media/v1/_base.py Outdated
Show resolved Hide resolved synapse/rest/media/v1/_base.py Outdated
Show resolved Hide resolved synapse/rest/media/v1/_base.py Outdated
Show resolved Hide resolved tests/rest/media/v1/test_media_storage.py Outdated
@richvdh

This comment has been minimized.

Copy link
Member

richvdh commented Nov 13, 2018

I'm assuming this is meant to fix #4160

richvdh and others added some commits Nov 13, 2018

Update synapse/rest/media/v1/_base.py
Co-Authored-By: hawkowl <hawkowl@atleastfornow.net>
Merge branch 'hawkowl/py3-content-disposition' of github.com:matrix-o…
…rg/synapse into hawkowl/py3-content-disposition

@hawkowl hawkowl requested a review from matrix-org/synapse-core Nov 13, 2018

@richvdh

This comment has been minimized.

Copy link
Member

richvdh commented Nov 15, 2018

pending merge of #4180 then

@richvdh richvdh removed the request for review from matrix-org/synapse-core Nov 15, 2018

@hawkowl hawkowl requested a review from richvdh Nov 15, 2018

@richvdh
Copy link
Member

richvdh left a comment

lgtm apart from some nits about comments

if not content_disposition[0]:
return

params = {}

This comment has been minimized.

@richvdh

richvdh Nov 15, 2018

Member

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)

upload_name_utf8 = upload_name_utf8[7:]
if PY3:
try:
# We have a filename*= section. This MUST be ASCII, and any

This comment has been minimized.

@richvdh

richvdh Nov 15, 2018

Member

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?

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

This comment has been minimized.

@richvdh

richvdh Nov 15, 2018

Member

"decoded" is unclear to me. Can we say something like:

First decode the ascii bytes to a str, then we can %-decode it safely

# Incorrect UTF-8.
pass
else:
# On Python 2, we can unquote it directly, and then decode it

This comment has been minimized.

@richvdh

richvdh Nov 15, 2018

Member
Suggested change Beta
# 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
@richvdh
Copy link
Member

richvdh left a comment

lgtm

@hawkowl hawkowl merged commit 8b1affe into develop Nov 15, 2018

5 checks passed

ci/circleci: sytestpy2merged Your tests passed on CircleCI!
Details
ci/circleci: sytestpy2postgresmerged Your tests passed on CircleCI!
Details
ci/circleci: sytestpy3merged Your tests passed on CircleCI!
Details
ci/circleci: sytestpy3postgresmerged Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@hawkowl hawkowl deleted the hawkowl/py3-content-disposition branch Nov 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment