From 80b3f21269c4d1b49fddd1080433634d4fc9bbfa 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 437c406e9bb9c..b793cfcf5d7bc 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; }