summaryrefslogtreecommitdiff
path: root/tests/admin_scripts/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/admin_scripts/views.py')
-rw-r--r--tests/admin_scripts/views.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/admin_scripts/views.py b/tests/admin_scripts/views.py
new file mode 100644
index 0000000000..d57803659d
--- /dev/null
+++ b/tests/admin_scripts/views.py
@@ -0,0 +1,17 @@
+from pathlib import Path
+
+from django.http import FileResponse
+
+
+def template_bad_filename(request):
+ content = Path(__file__).parent / "custom_templates" / "project_template.tgz"
+ f = open(content, "rb")
+ filename = "/nonexistent/archive.tgz"
+ response = FileResponse(
+ f,
+ as_attachment=True,
+ filename=filename,
+ )
+ # Force the filename to have a slash at the beginning.
+ response["Content-Disposition"] = f'attachment; filename="{filename}"'
+ return response