From 72655611ceb2501916684fc630710775cf777b0e Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 11 Aug 2019 16:52:09 -0700 Subject: [PATCH] requirements: Use maintained fork django-sendfile2 of django-sendfile The original seems to be unmaintained (johnsensible/django-sendfile#65). Notably, this fixes a bug in the filename parameter, which perviously showed the Python 3 repr of a byte string (johnsensible/django-sendfile#49). Signed-off-by: Anders Kaseorg --- requirements/common.in | 2 +- requirements/dev.txt | 2 +- requirements/prod.txt | 2 +- version.py | 2 +- zerver/tests/test_upload.py | 8 ++++---- zerver/views/upload.py | 7 ++++--- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/requirements/common.in b/requirements/common.in index 4102c59067..125a6c528e 100644 --- a/requirements/common.in +++ b/requirements/common.in @@ -159,7 +159,7 @@ twilio==6.29.2 stripe==2.21.0 # Needed for serving uploaded files from nginx but perform auth checks in django. -django-sendfile==0.3.11 +django-sendfile2==0.4.2 # For checking whether email of the user is from a disposable email provider. disposable-email-domains==0.0.52 diff --git a/requirements/dev.txt b/requirements/dev.txt index c5d960908c..baac91e10a 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -54,7 +54,7 @@ django-formtools==2.1 # via django-two-factor-auth django-otp==0.6.0 # via django-two-factor-auth django-phonenumber-field==1.3.0 # via django-two-factor-auth django-pylibmc==0.6.1 -django-sendfile==0.3.11 +django-sendfile2==0.4.2 django-statsd-mozilla==0.4.0 django-two-factor-auth==1.9.1 django-webpack-loader==0.6.0 diff --git a/requirements/prod.txt b/requirements/prod.txt index 4cce4e59f2..319bc9379f 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -39,7 +39,7 @@ django-formtools==2.1 # via django-two-factor-auth django-otp==0.6.0 # via django-two-factor-auth django-phonenumber-field==1.3.0 # via django-two-factor-auth django-pylibmc==0.6.1 -django-sendfile==0.3.11 +django-sendfile2==0.4.2 django-statsd-mozilla==0.4.0 django-two-factor-auth==1.9.1 django-webpack-loader==0.6.0 diff --git a/version.py b/version.py index 07e4bc7866..dc5e38ecd7 100644 --- a/version.py +++ b/version.py @@ -26,4 +26,4 @@ LATEST_RELEASE_ANNOUNCEMENT = "https://blog.zulip.org/2019/03/01/zulip-2-0-relea # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = '47.0' +PROVISION_VERSION = '48.0' diff --git a/zerver/tests/test_upload.py b/zerver/tests/test_upload.py index 1e46f9dea2..ce6d5348fb 100644 --- a/zerver/tests/test_upload.py +++ b/zerver/tests/test_upload.py @@ -708,14 +708,14 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase): else: self.assertEqual(response.get('Content-disposition'), None) - check_xsend_links('zulip.txt', 'zulip.txt', "filename*=UTF-8''zulip.txt") + check_xsend_links('zulip.txt', 'zulip.txt', 'filename="zulip.txt"') check_xsend_links('áéБД.txt', '%C3%A1%C3%A9%D0%91%D0%94.txt', "filename*=UTF-8''%C3%A1%C3%A9%D0%91%D0%94.txt") - check_xsend_links('zulip.html', 'zulip.html', "filename*=UTF-8''zulip.html") - check_xsend_links('zulip.sh', 'zulip.sh', "filename*=UTF-8''zulip.sh") + check_xsend_links('zulip.html', 'zulip.html', 'filename="zulip.html"') + check_xsend_links('zulip.sh', 'zulip.sh', 'filename="zulip.sh"') check_xsend_links('zulip.jpeg', 'zulip.jpeg') check_xsend_links('áéБД.pdf', '%C3%A1%C3%A9%D0%91%D0%94.pdf') - check_xsend_links('zulip', 'zulip', "filename*=UTF-8''zulip") + check_xsend_links('zulip', 'zulip', 'filename="zulip"') def tearDown(self) -> None: destroy_uploads() diff --git a/zerver/views/upload.py b/zerver/views/upload.py index 59146bcdfc..7c64910aaf 100644 --- a/zerver/views/upload.py +++ b/zerver/views/upload.py @@ -24,11 +24,12 @@ def serve_local(request: HttpRequest, path_id: str) -> HttpResponse: # an attachment (and thus clicking a link to it should download) # or like a link (and thus clicking a link to it should display it # in a browser tab). This is controlled by the - # Content-Disposition header; `django-sendfile` sends the + # Content-Disposition header; `django-sendfile2` sends the # attachment-style version of that header if and only if the # attachment argument is passed to it. For attachments, - # django-sendfile sets the response['Content-disposition'] like - # this: `attachment; filename="b'zulip.txt'"; filename*=UTF-8''zulip.txt`. + # django-sendfile2 sets the response['Content-disposition'] like + # this: `attachment; filename="zulip.txt"; filename*=UTF-8''zulip.txt`. + # The filename* parameter is omitted for ASCII filenames like this one. # # The "filename" field (used to name the file when downloaded) is # unreliable because it doesn't have a well-defined encoding; the