MDL-84480 files: correct text formatting params when filtering files.

This commit is contained in:
Paul Holden
2025-03-11 10:29:58 +00:00
parent 8cb5d000a1
commit 705d8e3471
+6 -5
View File
@@ -2616,7 +2616,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) {
@@ -2624,15 +2625,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) {
@@ -2640,10 +2642,9 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
} else {
$text = htmlentities(implode('', file($path)), ENT_QUOTES, 'UTF-8');
}
$output = '<pre>'. format_text($text, FORMAT_MOODLE, $options, $COURSE->id) .'</pre>';
$output = '<pre>'. format_text($text, FORMAT_MOODLE, $options) .'</pre>';
readstring_accel($output, $mimetype);
} else {
// send the contents
if ($pathisstring) {