-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not allow users to submit zip files when we need language detection
It is not the use case (it was done mostly for output only), and I think it's broken now as we look for files called "filename.%l" when the files in the zip are obviously called something like "filename.cpp".
- Loading branch information
1 parent
a47ea46
commit 10cb40f
Showing
4 changed files
with
37 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
# Contest Management System - http://cms-dev.github.io/ | ||
# Copyright © 2010-2014 Giovanni Mascellani <[email protected]> | ||
# Copyright © 2010-2015 Stefano Maggiolo <[email protected]> | ||
# Copyright © 2010-2016 Stefano Maggiolo <[email protected]> | ||
# Copyright © 2010-2012 Matteo Boscariol <[email protected]> | ||
# Copyright © 2012-2014 Luca Wehrstedt <[email protected]> | ||
# Copyright © 2013 Bernard Blackham <[email protected]> | ||
|
@@ -228,6 +228,11 @@ def post(self, task_name): | |
self.redirect("/testing?%s" % quote(task.name, safe='')) | ||
return | ||
|
||
# Required files from the user. | ||
required = set([sfe.filename for sfe in task.submission_format] + | ||
task_type.get_user_managers(task.submission_format) + | ||
["input"]) | ||
|
||
# Ensure that the user did not submit multiple files with the | ||
# same name. | ||
if any(len(filename) != 1 for filename in self.request.files.values()): | ||
|
@@ -241,9 +246,20 @@ def post(self, task_name): | |
return | ||
|
||
# If the user submitted an archive, extract it and use content | ||
# as request.files. | ||
# as request.files. But only valid for "output only" (i.e., | ||
# not for submissions requiring a programming language | ||
# identification). | ||
if len(self.request.files) == 1 and \ | ||
self.request.files.keys()[0] == "submission": | ||
if any(filename.endswith(".%l") for filename in required): | ||
self.application.service.add_notification( | ||
participation.user.username, | ||
self.timestamp, | ||
self._("Invalid test format!"), | ||
self._("Please select the correct files."), | ||
NOTIFICATION_ERROR) | ||
self.redirect("/testing?%s" % quote(task.name, safe='')) | ||
return | ||
archive_data = self.request.files["submission"][0] | ||
del self.request.files["submission"] | ||
|
||
|
@@ -275,9 +291,6 @@ def post(self, task_name): | |
# This ensure that the user sent one file for every name in | ||
# submission format and no more. Less is acceptable if task | ||
# type says so. | ||
required = set([sfe.filename for sfe in task.submission_format] + | ||
task_type.get_user_managers(task.submission_format) + | ||
["input"]) | ||
provided = set(self.request.files.keys()) | ||
if not (required == provided or (task_type.ALLOW_PARTIAL_SUBMISSION | ||
and required.issuperset(provided))): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters