csv: keep on failing on nul bytes (#86355)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Frédéric Péters 2024-01-31 09:44:13 +01:00
parent 1c7f6c2557
commit 129e2a5af3
1 changed files with 2 additions and 0 deletions

View File

@ -251,6 +251,8 @@ class CsvDataSource(BaseResource):
file_type = self.csv_file.name.split('.')[-1]
if file_type not in ('ods', 'xls', 'xlsx'):
content = self.get_content_without_bom()
if '\x00' in content:
raise ValueError(_('line contains NUL'))
reader = csv.reader(content.splitlines(), **self.dialect_options)
rows = list(reader)