@@ -123,17 +123,20 @@ def adjust_submission_form(self, request, form, problem_instance):
123
123
if form .kind != 'TESTRUN' :
124
124
return
125
125
126
+ # We need to check using is_zipfile, as sioworkers do the same.
127
+ # Otherwise one could bypass checks and limits for example by
128
+ # uploading a zipfile without the '.zip' extension.
126
129
def validate_file_size (file ):
127
130
if (
128
- file . name . upper (). endswith ( ".ZIP" )
131
+ is_zipfile ( file )
129
132
and file .size > self .get_testrun_zipped_input_limit ()
130
133
):
131
134
raise ValidationError (_ ("Zipped input file size limit exceeded." ))
132
135
elif file .size > self .get_testrun_input_limit ():
133
136
raise ValidationError (_ ("Input file size limit exceeded." ))
134
137
135
138
def validate_zip (file ):
136
- if file . name . upper (). endswith ( ".ZIP" ):
139
+ if is_zipfile ( file ):
137
140
archive = Archive (file , '.zip' )
138
141
if len (archive .filenames ()) != 1 :
139
142
raise ValidationError (_ ("Archive should have only 1 file inside." ))
@@ -279,7 +282,7 @@ def render_submission(self, request, submission):
279
282
context = {
280
283
'submission' : submission_template_context (request , sbm_testrun ),
281
284
'supported_extra_args' : self .get_supported_extra_args (submission ),
282
- 'input_is_zip' : is_zipfile (sbm_testrun .input_file ),
285
+ 'input_is_zip' : is_zipfile (sbm_testrun .input_file . read_using_cache () ),
283
286
},
284
287
)
285
288
@@ -295,7 +298,7 @@ def _render_testrun_report(
295
298
input_is_zip = False
296
299
if testrun_report :
297
300
input_is_zip = is_zipfile (
298
- testrun_report .submission_report .submission .programsubmission .testrunprogramsubmission .input_file
301
+ testrun_report .submission_report .submission .programsubmission .testrunprogramsubmission .input_file . read_using_cache ()
299
302
)
300
303
301
304
return render_to_string (
0 commit comments