From 05d110d4182beaaf87c5b3c9162c3c9495983e11 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 6 May 2021 15:57:23 +0200 Subject: [PATCH] rsa13: add BOM to CSV UTF-8 content (#53821) --- passerelle/contrib/rsa13/models.py | 2 +- tests/test_rsa13.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/passerelle/contrib/rsa13/models.py b/passerelle/contrib/rsa13/models.py index e800cfbe..b81d8acd 100644 --- a/passerelle/contrib/rsa13/models.py +++ b/passerelle/contrib/rsa13/models.py @@ -627,7 +627,7 @@ class RSA13Resource(BaseResource, HTTPResource): content = self.get('platform/%s/beneficiaire/csv/' % platform_id, email=email, ip=ip, params=params) data = content['data'] - response = HttpResponse(content_type='text/csv') + response = HttpResponse(content_type='text/csv', charset='utf_8_sig') date = now().strftime('%Y-%m-%d_%H:%M') response['Content-Disposition'] = 'attachment; filename="beneficiaires-%s.csv"' % date writer = csv.writer(response, delimiter=';') diff --git a/tests/test_rsa13.py b/tests/test_rsa13.py index a0e03b85..71ebd341 100644 --- a/tests/test_rsa13.py +++ b/tests/test_rsa13.py @@ -340,7 +340,7 @@ def test_platform_beneficiaire_csv(app, rsa13, url): ) assert ( response.content - == b'''NUM_CAF;CODE_PER;NOM_PER;PRENOM_PER;DTNAI_PER;ACTIF_PER;CODE_PI;LIB_CODE_PI;TOPPERSDRODEVORSA;LIB_ETATDOSRSA;LIB_MOTIF_ETATDOSRSA;NB_JOUR_DEPUIS_ARR;DATE_DEB;DATE_1IERE_CONS;DATE_DERNIERE_CONSULT;DATE_REELLE_RDV;NUM_CINS;DATE_SIGN;DATE_DEB_CI;DATE_FIN_CI;REFERENT_CI;ACTION_EN_COURS;DELAI_REGUL;PROC_EN_COURS;REFERENT_AFFECTATION\r\n1234;1234;nom;prenom;1234;1234;;;;;;;;;;;;;;;;;;;\r\n''' + == b'''\xef\xbb\xbfNUM_CAF;CODE_PER;NOM_PER;PRENOM_PER;DTNAI_PER;ACTIF_PER;CODE_PI;LIB_CODE_PI;TOPPERSDRODEVORSA;LIB_ETATDOSRSA;LIB_MOTIF_ETATDOSRSA;NB_JOUR_DEPUIS_ARR;DATE_DEB;DATE_1IERE_CONS;DATE_DERNIERE_CONSULT;DATE_REELLE_RDV;NUM_CINS;DATE_SIGN;DATE_DEB_CI;DATE_FIN_CI;REFERENT_CI;ACTION_EN_COURS;DELAI_REGUL;PROC_EN_COURS;REFERENT_AFFECTATION\r\n1234;1234;nom;prenom;1234;1234;;;;;;;;;;;;;;;;;;;\r\n''' # NOQA E501 ) -- 2.31.1