mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-59681 file: Stop recursive file serving
This commit is contained in:
parent
0d0f09bc7f
commit
34efb9a19e
@ -2678,6 +2678,8 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
|
|||||||
function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownload=false, array $options=array()) {
|
function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownload=false, array $options=array()) {
|
||||||
global $CFG, $COURSE;
|
global $CFG, $COURSE;
|
||||||
|
|
||||||
|
static $recursion = 0;
|
||||||
|
|
||||||
if (empty($options['filename'])) {
|
if (empty($options['filename'])) {
|
||||||
$filename = null;
|
$filename = null;
|
||||||
} else {
|
} else {
|
||||||
@ -2721,6 +2723,13 @@ function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownloa
|
|||||||
|
|
||||||
// handle external resource
|
// handle external resource
|
||||||
if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) {
|
if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) {
|
||||||
|
|
||||||
|
// Have we been here before?
|
||||||
|
$recursion++;
|
||||||
|
if ($recursion > 10) {
|
||||||
|
throw new coding_exception('Recursive file serving detected');
|
||||||
|
}
|
||||||
|
|
||||||
$stored_file->send_file($lifetime, $filter, $forcedownload, $options);
|
$stored_file->send_file($lifetime, $filter, $forcedownload, $options);
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user