diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2022-07-27 10:27:42 +0200 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2022-08-03 08:48:00 +0200 |
| commit | b7d9529cbe0af4adabb6ea5d01ed8dcce3668fb3 (patch) | |
| tree | 4aa0035fdcf98341989045b21967255e35be9070 /django | |
| parent | 2eb7dedd8f40f911d581d4e7619c046cefe203ce (diff) | |
[4.0.x] Fixed CVE-2022-36359 -- Escaped filename in Content-Disposition header.
Thanks to Motoyasu Saburi for the report.
Diffstat (limited to 'django')
| -rw-r--r-- | django/http/response.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/http/response.py b/django/http/response.py index 7fbec9d223..aa76305dbe 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -520,7 +520,9 @@ class FileResponse(StreamingHttpResponse): disposition = "attachment" if self.as_attachment else "inline" try: filename.encode("ascii") - file_expr = 'filename="{}"'.format(filename) + file_expr = 'filename="{}"'.format( + filename.replace("\\", "\\\\").replace('"', r"\"") + ) except UnicodeEncodeError: file_expr = "filename*=utf-8''{}".format(quote(filename)) self.headers["Content-Disposition"] = "{}; {}".format( |
