aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/studip_controller.php
diff options
context:
space:
mode:
authorAndré Noack <noack@data-quest.de>2023-12-21 14:32:21 +0000
committerElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2023-12-21 14:32:21 +0000
commitd4deb791aa1c4f403eb0f89e14c003aa05e30abe (patch)
treed8ece22aeff8f6417f6511b76b59ecee47b87a09 /app/controllers/studip_controller.php
parent85f82a53edf169f342c11f1db4f457cfe264817f (diff)
Resolve "OER-Campus: File upload vulnerabilities"
Closes #3586 and #3587 Merge request studip/studip!2480
Diffstat (limited to 'app/controllers/studip_controller.php')
-rw-r--r--app/controllers/studip_controller.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/studip_controller.php b/app/controllers/studip_controller.php
index 1ddce67..7a4da54 100644
--- a/app/controllers/studip_controller.php
+++ b/app/controllers/studip_controller.php
@@ -504,8 +504,15 @@ abstract class StudipController extends Trails_Controller
}
if ($content_type === null) {
- $finfo = finfo_open(FILEINFO_MIME_TYPE);
- $content_type = finfo_file($finfo, $file);
+ $content_type = get_mime_type($filename ?: $file);
+ }
+
+ if (!in_array($content_type, get_mime_types())) {
+ $content_type = 'application/octet-stream';
+ }
+
+ if ($content_type === 'application/octet-stream') {
+ $content_disposition = 'attachment';
}
$this->set_content_type($content_type);