detect mimetypes on server-side instead of relying on mimetype reported by client (Issue #202)

This commit is contained in:
coderkun 2014-05-03 16:32:26 +02:00
commit 3e37012ba0
3 changed files with 34 additions and 4 deletions

View file

@ -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'])
);
}