Skip to content

Commit 7455876

Browse files
committed
added file type migration; updated readme
1 parent 585563f commit 7455876

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

Services/MediaObjects/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
- ILIAS 8 supports external youtube and vimeo references. Since it uses mediaelement.js for rendering, not all features of youtube and vimeo are supported. On the other hand mediaelement.js is not able to fully deactivate/hide all features of the native youtube or vimeo presentation.
1212
- Please note that uploaded svg files will be processed by a sanitizer to eliminate potential insecure parts. This might even lead to non-working svg files, if they rely on these features.
1313
- PDF rendering support is limited. You might get different results, depending on server configuration and browser version. ILIAS renders the PDF as iframe with a src attribute pointing to the PDF file. The server must be configured to sent PDF files as application/pdf. The browser has to include a builtin PDF viewer. You should at least specify a height either directly or through content CSS rules.
14-
- HTML media objects need to be activated in the admininistration under "Repository and Objects > Allowed File Types". Please note that this is a potential security risk since this allows to upload HTML/Javascript, e.g. in page editor content. This content is rendered in iframes and since all media objects are located in a special folder, you might try to configure your webserver in a sub-domain isolation manner (currently untested). Since iframes are used you should at least specify a height either directly or through content CSS rules.
14+
- HTML media objects need to be activated in the admininistration under "Repository and Objects > Allowed File Types" (file suffixes up to ILIAS 8, mime types since ILIAS 9). Please note that this is a potential security risk since this allows to upload HTML/Javascript, e.g. in page editor content. This content is rendered in iframes and since all media objects are located in a special folder, you might try to configure your webserver in a sub-domain isolation manner (currently untested). Since iframes are used you should at least specify a height either directly or through content CSS rules.
1515
- Using the content style editor allows to define heights especially for PDF/HTML objects (keep the width empty to get a 100% width default behaviour.) e.g.
1616
- in px
1717
- relative to the viewport (e.g. setting "height: 80vh" as custom parameter)

Services/MediaObjects/classes/Setup/class.ilMediaObjectsDBUpdateSteps.php

+61
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,65 @@ public function step_1(): void
4242
));
4343
}
4444
}
45+
46+
public function step_2(): void
47+
{
48+
$db = $this->db;
49+
$set = $db->queryF(
50+
"SELECT * FROM settings " .
51+
" WHERE module = %s AND keyword = %s ",
52+
["text", "text"],
53+
["mobs", "black_list_file_types"]
54+
);
55+
$black_list_str = "";
56+
while ($rec = $db->fetchAssoc($set)) {
57+
$black_list_str = $rec["value"] ?? "";
58+
}
59+
$black_list = explode(",", $black_list_str);
60+
$new_black_list = [];
61+
foreach ($black_list as $type) {
62+
$type = strtolower(trim($type));
63+
switch ($type) {
64+
case "html": $type = "text/html";
65+
break;
66+
case "mp4": $type = "video/mp4";
67+
break;
68+
case "webm": $type = "video/webm";
69+
break;
70+
case "mp3": $type = "audio/mpeg";
71+
break;
72+
case "png": $type = "image/png";
73+
break;
74+
case "jpeg":
75+
case "jpg": $type = "image/jpeg";
76+
break;
77+
case "gif": $type = "image/gif";
78+
break;
79+
case "webp": $type = "image/webp";
80+
break;
81+
case "svg": $type = "image/svg+xml";
82+
break;
83+
case "pdf": $type = "application/pdf";
84+
break;
85+
}
86+
if (in_array($type, ["video/vimeo", "video/youtube", "video/mp4", "video/webm", "audio/mpeg",
87+
"image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml",
88+
"text/html", "application/pdf"])) {
89+
if (!in_array($type, $new_black_list)) {
90+
$new_black_list[] = $type;
91+
}
92+
}
93+
}
94+
$db->update(
95+
"settings",
96+
[
97+
"value" => ["text", implode(",", $new_black_list)]
98+
],
99+
[ // where
100+
"module" => ["text", "mobs"],
101+
"keyword" => ["text", "black_list_file_types"]
102+
]
103+
);
104+
}
105+
45106
}

0 commit comments

Comments
 (0)