diff --git a/lib/filelib.php b/lib/filelib.php index 0b3b4b7f74a..98c487b36b3 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -2629,7 +2629,8 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring if ($mimetype == 'text/html' || $mimetype == 'application/xhtml+xml' || file_is_svg_image_from_mimetype($mimetype)) { $options = new stdClass(); $options->noclean = true; - $options->nocache = true; // temporary workaround for MDL-5136 + $options->context = context_course::instance($COURSE->id); + if (is_object($path)) { $text = $path->get_content(); } else if ($pathisstring) { @@ -2637,15 +2638,16 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring } else { $text = implode('', file($path)); } - $output = format_text($text, FORMAT_HTML, $options, $COURSE->id); + $output = format_text($text, FORMAT_HTML, $options); readstring_accel($output, $mimetype); - } else if (($mimetype == 'text/plain') and ($filter == 1)) { // only filter text if filter all files is selected $options = new stdClass(); $options->newlines = false; $options->noclean = true; + $options->context = context_course::instance($COURSE->id); + if (is_object($path)) { $text = htmlentities($path->get_content(), ENT_QUOTES, 'UTF-8'); } else if ($pathisstring) { @@ -2653,10 +2655,9 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring } else { $text = htmlentities(implode('', file($path)), ENT_QUOTES, 'UTF-8'); } - $output = '
'. format_text($text, FORMAT_MOODLE, $options, $COURSE->id) .''; + $output = '
'. format_text($text, FORMAT_MOODLE, $options) .''; readstring_accel($output, $mimetype); - } else { // send the contents if ($pathisstring) {