From 0dfa958d0db08db80e94235455a691c40173847d Mon Sep 17 00:00:00 2001 From: Rossco Hellmans Date: Fri, 13 Dec 2024 14:08:56 +1000 Subject: [PATCH] MDL-65355 course: Render course search encoded characters correctly --- course/renderer.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/course/renderer.php b/course/renderer.php index 3d8b7e5f5aede..fee1da9f0cda5 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -2022,7 +2022,10 @@ public function get_course_formatted_summary($course, $options = array()) { $summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null); $summary = format_text($summary, $course->summaryformat, $options); if (!empty($this->searchcriteria['search'])) { - $summary = highlight($this->searchcriteria['search'], $summary); + // The course summary we are highlighting is a formatted string, + // so the search term should also be a formatted string to match. + $search = format_string($this->searchcriteria['search'], true, $options); + $summary = highlight($search, $summary); } return $summary; } @@ -2041,7 +2044,10 @@ public function get_course_formatted_name($course, $options = array()) { } $name = format_string(get_course_display_name_for_list($course), true, $options); if (!empty($this->searchcriteria['search'])) { - $name = highlight($this->searchcriteria['search'], $name); + // The course name we are highlighting is a formatted string, + // so the search term should also be a formatted string to match. + $search = format_string($this->searchcriteria['search'], true, $options); + $name = highlight($search, $name); } return $name; }