From 56372af486db74550d67e846d55002e9175f172c Mon Sep 17 00:00:00 2001 From: sylvain Date: Sun, 8 Mar 2026 17:55:28 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20t=C3=A9l=C3=A9chargement=20ICS=20:=20enco?= =?UTF-8?q?dage=20RFC=205987=20pour=20noms=20de=20fichiers=20non-ASCII?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le header Content-Disposition avec filename="Là_où_bat_le_cœur.ics" causait une erreur 500 car les caractères non-ASCII ne sont pas valides en HTTP. Correction avec filename*=UTF-8'' (RFC 5987). Co-Authored-By: Claude Sonnet 4.6 --- webapp/app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webapp/app.py b/webapp/app.py index 73e246f..a4355e3 100644 --- a/webapp/app.py +++ b/webapp/app.py @@ -11,6 +11,8 @@ from datetime import datetime from pathlib import Path from typing import Optional +from urllib.parse import quote + from fastapi import FastAPI, Depends, File, HTTPException, Request, Response, UploadFile, Cookie from fastapi.responses import FileResponse, StreamingResponse from fastapi.staticfiles import StaticFiles @@ -280,9 +282,10 @@ async def download_ics( ics_path = DATA_DIR / "jobs" / job_id / filename if not ics_path.exists(): raise HTTPException(404, "Fichier introuvable") + encoded = quote(filename, safe='') return FileResponse( - ics_path, media_type="text/calendar", filename=filename, - headers={"Content-Disposition": f'attachment; filename="{filename}"'}, + ics_path, media_type="text/calendar", + headers={"Content-Disposition": f"attachment; filename*=UTF-8''{encoded}"}, )