MDL-81781 report_log: escape description selectively on display/export.

Per cd85e090f3 all content was escaped, however we should only do that
when displaying the value in browser or exporting to file format which
supports HTML.
This commit is contained in:
Paul Holden 2024-05-07 17:15:22 +01:00
parent f2dbbfe66e
commit 222fb603c0
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -22,9 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core\dataformat;
use core\report_helper;
defined('MOODLE_INTERNAL') || die;
global $CFG;
require_once($CFG->libdir . '/tablelib.php');
@ -299,8 +301,11 @@ class report_log_table_log extends table_sql {
* @return string HTML for the description column
*/
public function col_description($event) {
// Description.
return format_text($event->get_description(), FORMAT_PLAIN);
if (empty($this->download) || dataformat::get_format_instance($this->download)->supports_html()) {
return format_text($event->get_description(), FORMAT_PLAIN);
} else {
return $event->get_description();
}
}
/**