From 394887aff637541f6fd2916ed1e0602f06f67dfb Mon Sep 17 00:00:00 2001 From: Mawoka Date: Mon, 5 Dec 2022 18:19:34 +0100 Subject: [PATCH] :bug: Fixed ascii-encoding in headers --- classquiz/routers/eximport.py | 2 +- classquiz/routers/quiz.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classquiz/routers/eximport.py b/classquiz/routers/eximport.py index c0ddbff..3423a46 100644 --- a/classquiz/routers/eximport.py +++ b/classquiz/routers/eximport.py @@ -59,7 +59,7 @@ async def export_quiz(quiz_id: uuid.UUID, user: User = Depends(get_current_user) stream_response(), media_type="application/octet-stream", headers={ - "Content-Disposition": f"attachment;filename={quiz.title}.cqa" + "Content-Disposition": f"attachment;filename={quiz.title.encode('ascii', errors='ignore').decode()}.cqa" # noqa: E501 }, ) diff --git a/classquiz/routers/quiz.py b/classquiz/routers/quiz.py index eeb1eb2..44f9b85 100644 --- a/classquiz/routers/quiz.py +++ b/classquiz/routers/quiz.py @@ -270,6 +270,6 @@ async def export_quiz_answers(export_token: str, game_pin: str): iter_file(), media_type="application/vnd.ms-excel", headers={ - "Content-Disposition": f"attachment;filename=ClassQuiz-{quiz.title}-{datetime.now().strftime('%m-%d-%Y')}.xlsx" # noqa: E501 + "Content-Disposition": f"attachment;filename=ClassQuiz-{quiz.title.encode('ascii', errors='ignore').decode()}-{datetime.now().strftime('%m-%d-%Y')}.xlsx" # noqa: E501 }, )