Skip to content

Commit 9f42cde

Browse files
authored
Merge pull request #213 from jazzband/prepare-2.4
Prepare 2.4 release
2 parents 18cb41f + 5c8bbda commit 9f42cde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+181
-67
lines changed

.pre-commit-config.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: check-toml
6+
- id: check-yaml
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace
9+
- id: mixed-line-ending
10+
- id: file-contents-sorter
11+
files: docs/spelling_wordlist.txt
12+
- repo: https://github.com/pycqa/doc8
13+
rev: v1.1.1
14+
hooks:
15+
- id: doc8
16+
- repo: https://github.com/adamchainz/django-upgrade
17+
rev: 1.20.0
18+
hooks:
19+
- id: django-upgrade
20+
args: [--target-version, "4.2"]
21+
- repo: https://github.com/pre-commit/pygrep-hooks
22+
rev: v1.10.0
23+
hooks:
24+
- id: rst-backticks
25+
- id: rst-directive-colons
26+
- repo: https://github.com/pre-commit/mirrors-prettier
27+
rev: v4.0.0-alpha.8
28+
hooks:
29+
- id: prettier
30+
entry: env PRETTIER_LEGACY_CLI=1 prettier
31+
types_or: [javascript, css]
32+
args:
33+
- --trailing-comma=es5
34+
- repo: https://github.com/pre-commit/mirrors-eslint
35+
rev: v9.8.0
36+
hooks:
37+
- id: eslint
38+
additional_dependencies:
39+
40+
- "@eslint/[email protected]"
41+
- "globals"
42+
files: \.js?$
43+
types: [file]
44+
args:
45+
- --fix
46+
- repo: https://github.com/astral-sh/ruff-pre-commit
47+
rev: 'v0.5.5'
48+
hooks:
49+
- id: ruff
50+
args: [--fix, --exit-non-zero-on-fix]
51+
- id: ruff-format
52+
- repo: https://github.com/tox-dev/pyproject-fmt
53+
rev: 2.1.4
54+
hooks:
55+
- id: pyproject-fmt
56+
- repo: https://github.com/abravalheri/validate-pyproject
57+
rev: v0.18
58+
hooks:
59+
- id: validate-pyproject

.readthedocs.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
version: 2
6+
7+
build:
8+
os: ubuntu-22.04
9+
tools:
10+
python: "3.10"
11+
12+
sphinx:
13+
configuration: docs/conf.py
14+
15+
python:
16+
install:
17+
- method: pip
18+
path: .

AUTHORS

+11-10
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ Maintainer: Benoît Bryon <[email protected]>
66

77
Original code by `PeopleDoc <https://www.people-doc.com/>`_ team:
88

9-
* Nicolas Tobo <https://github.com/nicolastobo>
10-
* Lauréline Guérin <https://github.com/zebuline>
11-
* Gregory Tappero <https://github.com/gregtap>
12-
* Rémy Hubscher <https://github.com/natim>
9+
* Adam Chainz <[email protected]>
10+
* Aleksi Häkli <[email protected]>
1311
* Benoît Bryon <[email protected]>
14-
* Aleksi Häkli <https://github.com/aleksihakli>
15-
* Johnt Hagen <[email protected]>
12+
13+
* David Wolf <[email protected]>
14+
* Davide Setti <[email protected]>
15+
* Erik Dykema <[email protected]>
1616
* Fabre Florian <[email protected]>
17-
* Peter Marheine <[email protected]>
1817
* Hasan Ramezani <[email protected]>
1918
* Jannis Leidel <[email protected]>
20-
* Erik Dykema <[email protected]>
19+
* John Hagen <[email protected]>
20+
* Mariusz Felisiak <[email protected]>
21+
* Martin Bächtold <[email protected]>
2122
* Nikhil Benesch <[email protected]>
2223
* Omer Katz <[email protected]>
24+
* Peter Marheine <[email protected]>
2325
* René Leonhardt <[email protected]>
24-
* Adam Chainz <[email protected]>
25-
* Martin Bächtold <[email protected]>
26+
* Rémy HUBSCHER <[email protected]>
2627
* Tim Gates <[email protected]>
2728
* zero13cool <[email protected]>

CHANGELOG

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ This document describes changes between past releases. For information about
55
future releases, check `milestones`_ and :doc:`/about/vision`.
66

77

8-
2.4 (Unreleased)
8+
2.4 (2024-08-05)
99
----------------
1010

1111
- Drop support for Python 3.6
12+
- Escape malicious filenames
13+
- Handle headers in XAccel responses
1214

1315

1416
2.3 (2022-01-11)

CONTRIBUTING.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This is a `Jazzband <https://jazzband.co>`_ project. By contributing you agree t
1111

1212

1313
This document provides guidelines for people who want to contribute to
14-
`django-downloadview`.
14+
``django-downloadview``.
1515

1616

1717
**************
@@ -50,7 +50,7 @@ Use topic branches
5050
Fork, clone
5151
***********
5252

53-
Clone `django-downloadview` repository (adapt to use your own fork):
53+
Clone ``django-downloadview`` repository (adapt to use your own fork):
5454

5555
.. code:: sh
5656
@@ -62,15 +62,15 @@ Clone `django-downloadview` repository (adapt to use your own fork):
6262
Usual actions
6363
*************
6464

65-
The `Makefile` is the reference card for usual actions in development
65+
The ``Makefile`` is the reference card for usual actions in development
6666
environment:
6767

6868
* Install development toolkit with `pip`_: ``make develop``.
6969

7070
* Run tests with `tox`_: ``make test``.
7171

7272
* Build documentation: ``make documentation``. It builds `Sphinx`_
73-
documentation in `var/docs/html/index.html`.
73+
documentation in ``var/docs/html/index.html``.
7474

7575
* Release project with `zest.releaser`_: ``make release``.
7676

@@ -84,15 +84,15 @@ See also ``make help``.
8484
Demo project included
8585
*********************
8686

87-
The `demo` included in project's repository is part of the tests and
87+
The ``demo`` included in project's repository is part of the tests and
8888
documentation. Maintain it along with code and documentation.
8989

9090

9191
.. rubric:: Notes & references
9292

9393
.. target-notes::
9494

95-
.. _`bugtracker`:
95+
.. _`bugtracker`:
9696
https://github.com/jazzband/django-downloadview/issues
9797
.. _`rebase`: http://git-scm.com/book/en/Git-Branching-Rebasing
9898
.. _`merge-based rebase`: https://tech.people-doc.com/psycho-rebasing.html

README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ django-downloadview
2626
:target: https://codecov.io/gh/jazzband/django-downloadview
2727
:alt: Coverage
2828

29-
`django-downloadview` makes it easy to serve files with `Django`_:
29+
``django-downloadview`` makes it easy to serve files with `Django`_:
3030

3131
* you manage files with Django (permissions, filters, generation, ...);
3232

3333
* files are stored somewhere or generated somehow (local filesystem, remote
3434
storage, memory...);
3535

36-
* `django-downloadview` helps you stream the files with very little code;
36+
* ``django-downloadview`` helps you stream the files with very little code;
3737

38-
* `django-downloadview` helps you improve performances with reverse proxies,
38+
* ``django-downloadview`` helps you improve performances with reverse proxies,
3939
via mechanisms such as Nginx's X-Accel or Apache's X-Sendfile.
4040

4141

demo/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Demo project
33
############
44

55
`Demo folder in project's repository`_ contains a Django project to illustrate
6-
`django-downloadview` usage.
6+
``django-downloadview`` usage.
77

88

99
*****************************************
@@ -32,7 +32,7 @@ Deploy the demo
3232
System requirements:
3333

3434
* `Python`_ version 3.7+, available as ``python`` command.
35-
35+
3636
.. note::
3737

3838
You may use `Virtualenv`_ to make sure the active ``python`` is the right

demo/demoproject/apache/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ def test_response(self):
5858
basename="hello-world.txt",
5959
file_path="/apache-modified-headers/hello-world.txt",
6060
)
61-
self.assertEqual(response['X-Test'], 'header')
61+
self.assertEqual(response["X-Test"], "header")

demo/demoproject/apache/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""URL mapping."""
2+
23
from django.urls import path
34

45
from demoproject.apache import views

demo/demoproject/apache/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
def _modified_headers(request):
2828
view = StorageDownloadView.as_view(storage=storage, path="hello-world.txt")
2929
response = view(request)
30-
response["X-Test"] = 'header'
30+
response["X-Test"] = "header"
3131
return response
3232

3333

demo/demoproject/fixtures/demo.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[
22
{
3-
"pk": 1,
4-
"model": "object.document",
3+
"pk": 1,
4+
"model": "object.document",
55
"fields": {
6-
"slug": "hello-world",
6+
"slug": "hello-world",
77
"file": "object/hello-world.txt"
88
}
99
}

demo/demoproject/lighttpd/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ def test_response(self):
5858
basename="hello-world.txt",
5959
file_path="/lighttpd-modified-headers/hello-world.txt",
6060
)
61-
self.assertEqual(response['X-Test'], 'header')
61+
self.assertEqual(response["X-Test"], "header")

demo/demoproject/lighttpd/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""URL mapping."""
2+
23
from django.urls import path
34

45
from demoproject.lighttpd import views

demo/demoproject/lighttpd/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
def _modified_headers(request):
2828
view = StorageDownloadView.as_view(storage=storage, path="hello-world.txt")
2929
response = view(request)
30-
response["X-Test"] = 'header'
30+
response["X-Test"] = "header"
3131
return response
3232

3333

demo/demoproject/nginx/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ def test_response(self):
7070
with_buffering=None,
7171
limit_rate=None,
7272
)
73-
self.assertEqual(response['X-Test'], 'header')
73+
self.assertEqual(response["X-Test"], "header")

demo/demoproject/nginx/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
def _modified_headers(request):
2828
view = StorageDownloadView.as_view(storage=storage, path="hello-world.txt")
2929
response = view(request)
30-
response["X-Test"] = 'header'
30+
response["X-Test"] = "header"
3131
return response
3232

3333

demo/demoproject/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Django settings for django-downloadview demo project."""
2+
23
import os
34

45

demo/demoproject/storage/tests.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def test_not_modified_download_response(self):
4444
url = reverse("storage:static_path", kwargs={"path": "1.txt"})
4545
year = datetime.date.today().year + 4
4646
response = self.client.get(
47-
url,
48-
HTTP_IF_MODIFIED_SINCE=f"Sat, 29 Oct {year} 19:43:31 GMT",
47+
url, headers={"if-modified-since": f"Sat, 29 Oct {year} 19:43:31 GMT"}
4948
)
5049
self.assertTrue(isinstance(response, HttpResponseNotModified))
5150

@@ -55,7 +54,7 @@ def test_modified_since_download_response(self):
5554
setup_file("1.txt")
5655
url = reverse("storage:static_path", kwargs={"path": "1.txt"})
5756
response = self.client.get(
58-
url, HTTP_IF_MODIFIED_SINCE="Sat, 29 Oct 1980 19:43:31 GMT"
57+
url, headers={"if-modified-since": "Sat, 29 Oct 1980 19:43:31 GMT"}
5958
)
6059
assert_download_response(
6160
self,

demo/demoproject/tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test suite for demoproject.download."""
2+
23
from django.test import TestCase
34
from django.urls import reverse
45

demo/demoproject/wsgi.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
framework.
1313
1414
"""
15+
1516
import os
1617

1718
from django.core.wsgi import get_wsgi_application

django_downloadview/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Serve files with Django and reverse proxies."""
2+
23
from django_downloadview.api import * # NoQA
34

45
import importlib.metadata

django_downloadview/apache/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Apache optimizations </optimizations/apache>`.
66
77
"""
8+
89
# API shortcuts.
910
from django_downloadview.apache.decorators import x_sendfile # NoQA
1011
from django_downloadview.apache.middlewares import XSendfileMiddleware # NoQA

django_downloadview/apache/decorators.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Decorators to apply Apache X-Sendfile on a specific view."""
2+
23
from django_downloadview.apache.middlewares import XSendfileMiddleware
34
from django_downloadview.decorators import DownloadDecorator
45

django_downloadview/apache/response.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Apache's specific responses."""
2+
23
import os.path
34

45
from django_downloadview.response import ProxiedDownloadResponse, content_disposition
@@ -7,11 +8,13 @@
78
class XSendfileResponse(ProxiedDownloadResponse):
89
"Delegates serving file to Apache via X-Sendfile header."
910

10-
def __init__(self, file_path, content_type, basename=None, attachment=True, headers=None):
11+
def __init__(
12+
self, file_path, content_type, basename=None, attachment=True, headers=None
13+
):
1114
"""Return a HttpResponse with headers for Apache X-Sendfile."""
1215
# content-type must be provided only as keyword argument to response
1316
if headers and content_type:
14-
headers.pop('Content-Type', None)
17+
headers.pop("Content-Type", None)
1518
super().__init__(content_type=content_type, headers=headers)
1619
if attachment:
1720
self.basename = basename or os.path.basename(file_path)

django_downloadview/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# flake8: noqa
22
"""Declaration of API shortcuts."""
3+
34
from django_downloadview.files import HTTPFile, StorageFile, VirtualFile
45
from django_downloadview.io import BytesIteratorIO, TextIteratorIO
56
from django_downloadview.middlewares import (

django_downloadview/files.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""File wrappers for use as exchange data between views and responses."""
2+
23
from io import BytesIO
34
from urllib.parse import urlparse
45

django_downloadview/io.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Low-level IO operations, for use with file wrappers."""
2+
23
import io
34

45
from django.utils.encoding import force_bytes, force_str

django_downloadview/lighttpd/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</optimizations/lighttpd>`.
77
88
"""
9+
910
# API shortcuts.
1011
from django_downloadview.lighttpd.decorators import x_sendfile # NoQA
1112
from django_downloadview.lighttpd.middlewares import XSendfileMiddleware # NoQA

0 commit comments

Comments
 (0)