1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-24 17:42:23 +00:00

Only process CSV files when they are correctly read

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2023-04-08 17:33:01 +02:00
parent bcf4e294e0
commit 80cfe874f5
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -261,12 +261,11 @@ class UploadNotesForm(forms.Form):
with file:
try:
csvfile = csv.reader(StringIO(file.read().decode()))
self.process(csvfile, cleaned_data)
except UnicodeDecodeError:
self.add_error('file', _("This file contains non-UTF-8 content. "
"Please send your sheet as a CSV file."))
self.process(csvfile, cleaned_data)
return cleaned_data
def process(self, csvfile: Iterable[str], cleaned_data: dict):