Skip to content

Commit

Permalink
Merge branch 'MDL-72316-master-2' of git://github.com/mickhawkins/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta authored and andrewnicols committed Oct 28, 2021
2 parents 00483c9 + 2a2ece6 commit 4d10196
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/filelib.php
Expand Up @@ -2505,6 +2505,9 @@ function file_safe_save_content($content, $destination) {
* @param array $options An array of options, currently accepts:
* - (string) cacheability: public, or private.
* - (string|null) immutable
* - (bool) dontforcesvgdownload: true if force download should be disabled on SVGs.
* Note: This overrides a security feature, so should only be applied to "trusted" content
* (eg module content that is created using an XSS risk flagged capability, such as SCORM).
* @return null script execution stopped unless $dontdie is true
*/
function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='',
Expand Down Expand Up @@ -2535,8 +2538,9 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
$filename = rawurlencode($filename);
}

// Make sure we force download of SVG files for security reasons (https://digi.ninja/blog/svg_xss.php).
if (file_is_svg_image_from_mimetype($mimetype)) {
// Make sure we force download of SVG files, unless the module explicitly allows them (eg within SCORM content).
// This is for security reasons (https://digi.ninja/blog/svg_xss.php).
if (file_is_svg_image_from_mimetype($mimetype) && empty($options['dontforcesvgdownload'])) {
$forcedownload = true;
}

Expand Down
6 changes: 6 additions & 0 deletions lib/upgrade.txt
Expand Up @@ -111,6 +111,12 @@ completely removed from Moodle core too.
classes extending it. When possible, the enable_plugin() method will store these changes into the config_log table, to let admins
check when and who has enabled/disabled plugins.

=== 3.11.4 ===
* A new option dontforcesvgdownload has been added to the $options parameter of the send_file() function.
Note: This option overrides the forced download of directly accessed SVGs, so should only be used where the calling method is
rendering SVGs directly for content created using XSS risk flagged capabilities (such as creating a SCORM activity).
This is also not necessary where SVGs are already being safely loaded into <img> tags by Moodle (eg within forum posts).

=== 3.11.2 ===
* For security reasons, filelib has been updated so all requests now use emulated redirects.
For this reason, manually disabling emulateredirects will no longer have any effect (and will generate a debugging message).
Expand Down
3 changes: 3 additions & 0 deletions mod/scorm/lib.php
Expand Up @@ -1011,6 +1011,9 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
return false;
}

// Allow SVG files to be loaded within SCORM content, instead of forcing download.
$options['dontforcesvgdownload'] = true;

// Finally send the file.
send_stored_file($file, $lifetime, 0, false, $options);
}
Expand Down

0 comments on commit 4d10196

Please sign in to comment.