From 80cfe874f53df5d6d942d5ac670d9e0c8f5a807c Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 8 Apr 2023 17:33:01 +0200 Subject: [PATCH] Only process CSV files when they are correctly read Signed-off-by: Emmy D'Anello --- participation/forms.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/participation/forms.py b/participation/forms.py index 0a3f0f9..775422c 100644 --- a/participation/forms.py +++ b/participation/forms.py @@ -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):