Skip to content

Commit

Permalink
Change allowed filesize for zipfiles as solution uploads.
Browse files Browse the repository at this point in the history
This fixes KITPraktomatTeam/Praktomat/KITPraktomatTeam#359 , hso-praktomat/praktomat/KITPraktomatTeam#15
  • Loading branch information
Robert Hartmann (FB02, H-BRS) authored and Robert Hartmann (FB02, H-BRS) committed Jan 3, 2023
1 parent 3a1a6ad commit 04bc655
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/solutions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def clean_file(self):
zip = zipfile.ZipFile(data)
if zip.testzip():
raise forms.ValidationError(_('The zip file seems to be corrupt.'))
if sum(fileinfo.file_size for fileinfo in zip.infolist()) > max_file_size:
if sum(fileinfo.file_size for fileinfo in zip.infolist()) > ( max_file_size * len(zip.infolist()) ) :
# Protect against zip bombs
# but allow that a zip-file can be the same size like the sum of all file sizes would be, if files would have been uploaded seperately.
raise forms.ValidationError(_('The zip file is too big.'))
for fileinfo in zip.infolist():
filename = fileinfo.filename
Expand Down

0 comments on commit 04bc655

Please sign in to comment.