File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 33/* For licensing terms, see /license.txt */
44
55use ChamiloSession as Session ;
6+ use enshrined \svgSanitize \Sanitizer ;
67
78/**
89 * Class DocumentManager
@@ -486,6 +487,13 @@ public static function file_send_for_download(
486487 }
487488 echo $ content ;
488489 } else {
490+ if ('image/svg+xml ' === $ contentType ) {
491+ $ svgContent = file_get_contents ($ full_file_name );
492+
493+ echo (new Sanitizer ())->sanitize ($ svgContent );
494+ return true ;
495+ }
496+
489497 if (isset ($ enableMathJaxScript ) && $ enableMathJaxScript === true ) {
490498 $ content = file_get_contents ($ full_file_name );
491499 $ content = self ::includeMathJaxScript ($ content );
Original file line number Diff line number Diff line change @@ -1097,6 +1097,10 @@ public static function saveMessageAttachmentFile(
10971097 $ fileCopied = true ;
10981098 }
10991099 }
1100+
1101+ if ('image/svg+xml ' === $ type ) {
1102+ sanitizeSvgFile ($ new_path );
1103+ }
11001104 }
11011105
11021106 if ($ fileCopied ) {
Original file line number Diff line number Diff line change 99 *
1010 * @package chamilo.messages
1111 */
12+
13+ use Symfony \Component \HttpFoundation \Request as HttpRequest ;
14+
1215session_cache_limiter ('public ' );
1316
1417require_once __DIR__ .'/../inc/global.inc.php ' ;
2023header ('Cache-Control: public ' );
2124header ('Pragma: no-cache ' );
2225
23- $ messageId = isset ($ _GET ['message_id ' ]) ? $ _GET ['message_id ' ] : 0 ;
24- $ attachmentId = isset ($ _GET ['attachment_id ' ]) ? $ _GET ['attachment_id ' ] : 0 ;
26+ $ httpRequest = HttpRequest::createFromGlobals ();
27+
28+ $ messageId = $ httpRequest ->query ->getInt ('message_id ' );
29+ $ attachmentId = $ httpRequest ->query ->getInt ('attachment_id ' );
2530
2631$ messageInfo = MessageManager::get_message_by_id ($ messageId );
2732$ attachmentInfo = MessageManager::getAttachment ($ attachmentId );
You can’t perform that action at this time.
0 commit comments