detect mimetypes on server-side instead of relying on mimetype reported by client (Issue #202)
This commit is contained in:
parent
7b8f14af55
commit
3e37012ba0
3 changed files with 34 additions and 4 deletions
|
|
@ -56,15 +56,16 @@
|
|||
// Check mimetype
|
||||
$mimetypes = $this->Submit->getAllowedMimetypes($seminary['id']);
|
||||
$answerMimetype = null;
|
||||
$answer['mimetype'] = \hhu\z\Utils::getMimetype($answer['tmp_name']);
|
||||
foreach($mimetypes as &$mimetype) {
|
||||
if($mimetype['mimetype'] == $answer['type']) {
|
||||
if($mimetype['mimetype'] == $answer['mimetype']) {
|
||||
$answerMimetype = $mimetype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(is_null($answerMimetype)) {
|
||||
throw new \hhu\z\exceptions\SubmissionNotValidException(
|
||||
new \hhu\z\exceptions\WrongFiletypeException($answer['type'])
|
||||
new \hhu\z\exceptions\WrongFiletypeException($answer['mimetype'])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue