From 53c85e017d48a57de1f33a656ec9f53533bcc5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Fri, 13 Feb 2026 22:08:19 +0100 Subject: [PATCH] Fix X-Accel-Redirect with non-ASCII names --- ram/ram/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ram/ram/views.py b/ram/ram/views.py index 7dcee86..88c8b78 100644 --- a/ram/ram/views.py +++ b/ram/ram/views.py @@ -17,7 +17,7 @@ from django.http import ( ) from django.views import View from django.utils.text import slugify as slugify -from django.utils.encoding import smart_str +from django.utils.encoding import iri_to_uri, smart_str from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt @@ -112,7 +112,9 @@ class DownloadFile(View): if getattr(settings, "USE_X_ACCEL_REDIRECT", False): response = HttpResponse() response["Content-Type"] = "" - response["X-Accel-Redirect"] = f"/private/{file.name}" + response["X-Accel-Redirect"] = iri_to_uri( + f"/private/{file.name}" + ) else: response = FileResponse( open(file.path, "rb"), as_attachment=True